@@ -0,0 +1,1351 @@
+package leetcode.contains_duplicate_iii;%0A%0Aimport java.util.ArrayList;%0A%0Apublic class Solution %7B%0A    public boolean containsNearbyAlmostDuplicate(int%5B%5D nums, int k, int t) %7B%0A        if(k == 0) return false;%0A        ArrayList%3CInteger%3E window = new ArrayList%3CInteger%3E(k);%0A        if(nums == null %7C%7C nums.length == 0) return false;%0A        window.add(nums%5B0%5D);%0A        int L, U;%0A        for(int i = 1; i %3C nums.length; i++)%7B%0A            L = -1;%0A            U = window.size();%0A            while(L + 1 %3C U)%7B%0A                int mid = L + (U - L) / 2;%0A                if(window.get(mid) %3E nums%5Bi%5D)%7B%0A                    U = mid;%0A                %7Delse%7B%0A                    L = mid;%0A                %7D%0A            %7D%0A            if(L %3E= 0 && (long)nums%5Bi%5D - window.get(L) %3C= (long)t) return true;%0A            if(U %3C window.size() && (long)window.get(U) - nums%5Bi%5D %3C= (long)t) return true;%0A            window.add(U, nums%5Bi%5D);%0A            if(i %3E= k)%7B%0A                L = -1;%0A                U = window.size();%0A                while(L + 1 %3C U)%7B%0A                    int mid = L + (U - L) / 2;%0A                    if(window.get(mid) %3E nums%5Bi - k%5D)%7B%0A                        U = mid;%0A                    %7Delse%7B%0A                        L = mid;%0A                    %7D%0A                %7D%0A                window.remove(L);%0A            %7D%0A        %7D%0A        return false;%0A    %7D%0A%7D%0A

Add java solution for 220. Contains Duplicate III