Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and jis at most k.
和类似,多了个判断而已。
注意可能有多个重复,例如[1,0,1,1],1 为 True。
1 class Solution { 2 public: 3 bool containsNearbyDuplicate(vector & nums, int k) { 4 unordered_mapshowed; 5 for(int i=0;i