标签:
1 class Solution { 2 public: 3 bool containsNearbyDuplicate(vector<int>& nums, int k) { 4 map<int, int> m; 5 for (size_t i = 0; i < nums.size(); ++i) { 6 if (m.find(nums[i]) != m.end() && i - m[nums[i]] <= k) return true; 7 else m[nums[i]] = i; 8 } 9 return false; 10 } 11 };
标签:
原文地址:http://www.cnblogs.com/shadowwalker9/p/5970732.html