Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct.
题意:给出一组整数,找出是否包含相同的数
class Solution {
public:
bool containsDuplicate(vector<int>& nums) {
map<int, int> mii;
for(int i = 0; i < nums.size(); i++){
mii[nums[i]]++;
if(mii[nums[i]] > 1) return true;
}
return false;
}
};