@@ -0,0 +1,964 @@
+package LeetCode.Java;%0A%0A/**%0A * Created by Vonzpf on 17/4/6.%0A */%0A%0Aimport java.util.HashMap;%0A%0A/**-------------------------Title---------------------------------%0A Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array%0A%0A such that nums%5Bi%5D = nums%5Bj%5D and the absolute difference between i and j is at most k.%0A */%0Apublic class ContainsDuplicateII %7B%0A    public boolean containsNearbyDuplicate(int%5B%5D nums, int k) %7B%0A        HashMap%3CInteger, Integer%3E map = new HashMap%3CInteger, Integer%3E();%0A        for (int i = 0; i %3C nums.length; i++)%7B%0A            if (!map.containsKey(nums%5Bi%5D))%7B%0A                map.put(nums%5Bi%5D, i);%0A            %7D%0A            else%7B%0A                int j = map.get(nums%5Bi%5D);%0A                if(i - j %3C= k )%7B%0A                    return true;%0A                %7D%0A                else %7B%0A                    map.replace(nums%5Bi%5D, i);%0A                %7D%0A            %7D%0A        %7D%0A        return false;%0A    %7D%0A%7D%0A

219.Contains Duplicate II