반응형
class Solution {
public:
int repeatedNTimes(vector<int>& A) {
int array[10001] = {0};
int ans = 0;
for(int i = 0;i<A.size();i++){
array[A[i]]++;
if(array[A[i]] == 2){
ans = A[i];
break;
}
}
return ans;
}
};
반응형
'IT > 알고리즘' 카테고리의 다른 글
40] Leetcode 912. Sort an Array (0) | 2020.08.07 |
---|---|
39★] Leetcode 905. Sort Array By Parity (0) | 2020.08.06 |
37] Leetcode 1380. Lucky Numbers in a Matrix (0) | 2020.07.21 |
36] Leetcode 1460. Make Two Arrays Equal by Reversing Sub-arrays (0) | 2020.07.21 |
35★] Leetcode 1299. Replace Elements with Greatest Element on Right Side (0) | 2020.07.19 |
댓글