@@ -0,0 +1,1595 @@
+package leetcode.maximum_gap;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Apublic class Solution %7B%0A    public int maximumGap(int%5B%5D num) %7B%0A        if(num == null %7C%7C num.length %3C 2) return 0;%0A        int length = num.length;%0A        List%3CList%3CInteger%3E%3E buckets = new ArrayList%3CList%3CInteger%3E%3E(length - 1);%0A        for(int i = 0; i %3C length - 1; i++)%7B%0A        %09buckets.add(new ArrayList%3CInteger%3E());%0A        %7D%0A        int min = num%5B0%5D, max = num%5B0%5D;%0A        for(int x : num)%7B%0A        %09if(x %3C min)%7B%0A        %09%09min = x;%0A        %09%7D%0A        %09if(x %3E max)%7B%0A        %09%09max = x;%0A        %09%7D%0A        %7D%0A        int range = max - min;%0A        for(int x : num)%7B%0A        %09long diff = x - min;%0A        %09if(x %3C max)%7B%0A        %09%09int idx = (int)(diff * (length - 1) / range);%0A        %09%09buckets.get(idx).add(x);%0A        %09%7D%0A        %7D%0A        List%3CInteger%3E bmins = new ArrayList%3CInteger%3E();%0A        List%3CInteger%3E bmaxs = new ArrayList%3CInteger%3E();%0A        for(List%3CInteger%3E bucket : buckets)%7B%0A        %09if(bucket.size() %3E 0)%7B%0A        %09%09int bmin = bucket.get(0);%0A        %09%09int bmax = bucket.get(0);%0A        %09%09for(int b : bucket)%7B%0A        %09%09%09if(b %3C bmin)%0A        %09%09%09%09bmin = b;%0A        %09%09%09if(b %3E bmax)%0A        %09%09%09%09bmax = b;%0A        %09%09%7D%0A        %09%09bmins.add(bmin);%0A        %09%09bmaxs.add(bmax);%0A        %09%7D%0A        %7D%0A        int maxgap = 0;%0A        int currmin = min;%0A        int bsize = bmins.size();%0A        for(int i = 0; i %3C bsize; i++)%7B%0A        %09maxgap = Math.max(maxgap, bmins.get(i) - currmin);%0A        %09currmin = bmaxs.get(i);%0A        %7D%0A        maxgap = Math.max(maxgap, max - currmin);%0A        return maxgap;%0A    %7D%0A%7D%0A

Add java solution for 164. Maximum Gap