@@ -0,0 +1,633 @@
+package leetcode;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0A/**%0A * Created by pingcai on 17-7-13.%0A *%0A * %E6%B1%82%E6%95%B0%E7%BB%84%E9%87%8C%E6%98%AF%E5%90%A6%E5%8C%85%E5%90%AB%E8%B7%9D%E7%A6%BB%E5%9C%A8k%E4%B9%8B%E5%86%85%E7%9A%84%E4%B8%A4%E4%B8%AA%E7%9B%B8%E5%90%8C%E6%95%B0%0A *%0A * %E5%A6%82%EF%BC%9A arr = 1 9 8 7 8 3  k = 3 %E8%BF%94%E5%9B%9E true%0A *%0A *      arr = 1 9 8 7 8 3  k = 1 %E8%BF%94%E5%9B%9E false%0A */%0Apublic class _219_Contains_Duplicate_II %7B%0A    public boolean containsNearbyDuplicate(int%5B%5D nums, int k) %7B%0A        Map%3CInteger,Integer%3E map = new HashMap();%0A        int q = 0;%0A        for(int i =0;i%3Cnums.length;i++)%7B%0A            q = nums%5Bi%5D;%0A            if(map.get(q) != null && i - map.get(q) %3C= k)%7B%0A                return true;%0A            %7D%0A            map.put(q,i);%0A        %7D%0A        return false;%0A    %7D%0A%7D%0A

contains duplicate