Created
December 23, 2018 08:27
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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