class Solution { public: bool containsNearbyDuplicate(vector& nums, int k) { int size = nums.size(); // create the map, map key is the value of the vector element, map value is the index of that element in the vector. map map1; for(int i=0;i