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 };
posted @ 2016-01-16 20:23  Breeze0806  阅读(143)  评论(0编辑  收藏  举报