Skip to content

Instantly share code, notes, and snippets.

@fpdjsns
Created December 23, 2018 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fpdjsns/27f0bf48aac4a20315c2f41e8422c663 to your computer and use it in GitHub Desktop.
Save fpdjsns/27f0bf48aac4a20315c2f41e8422c663 to your computer and use it in GitHub Desktop.
[leetcode] 961. N-Repeated Element in Size 2N Array : https://leetcode.com/problems/n-repeated-element-in-size-2n-array/
class Solution {
public:
int repeatedNTimes(vector<int>& A) {
set<int> s;
for(int i=0;i<A.size();i++){
if(s.find(A[i])!=s.end()) return A[i];
s.insert(A[i]);
}
return -1;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment