Leetcode 328 Contains Duplicate set和map应用
找出数组中重复的数,裸的map和set题
1 class Solution { 2 public: 3 bool containsDuplicate(vector<int>& nums) { 4 map<int,int> mii; 5 for (int i = 0;i<nums.size() ;++i) 6 { 7 if (mii.find(nums[i]) != mii.end()) 8 { 9 return true; 10 } 11 mii[nums[i]] = i; 12 } 13 return false; 14 } 15 };