标签:
1 class Solution { 2 public: 3 bool containsNearbyDuplicate(vector<int>& nums, int k) { 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 if(i - mii[nums[i]] <= k) return true; 10 } 11 mii[nums[i]] = i; 12 } 13 return false; 14 } 15 };
Leetcode 219 Contains Duplicate II STL
标签:
原文地址:http://www.cnblogs.com/onlyac/p/5268431.html