Contains Duplicate: https://leetcode.com/problems/contains-duplicate/
104ms
104ms
PHP Code:
class Solution {
public:
bool containsDuplicate(vector<int>& nums) {
int i, j, k=0;
int n=nums.size();
map<int, int> c;
for(i=0; i<n; i++){
if(c[nums[i]]==1) return true;
else c[nums[i]]=1;
}
return false;
}
};
Comment