@@ -0,0 +1,1780 @@
+package leetcode.longest_consecutive_sequence;%0A%0Aimport java.util.HashMap;%0A%0Apublic class Solution %7B%0A%09public static class Interval %7B%0A%09%09public int start;%0A%09%09public int end;%0A%09%09public Interval() %7B start = 0; end = 0; %7D%0A%09%09public Interval(int s, int e) %7B start = s; end = e; %7D%0A%09%7D%0A%09%0A%09public int longestConsecutive(int%5B%5D num) %7B%0A    %09HashMap%3CInteger, Interval%3E leftMap = new HashMap%3CInteger, Interval%3E();%0A    %09HashMap%3CInteger, Interval%3E rightMap = new HashMap%3CInteger, Interval%3E();%0A    %09for(int x : num)%7B%0A    %09%09Interval asLeft = leftMap.get(x);%0A    %09%09Interval asRight = rightMap.get(x);%0A    %09%09if(asLeft != null %7C%7C asRight != null)%7B%0A    %09%09%09continue;%0A    %09%09%7D%0A    %09%09Interval leftIvl = rightMap.get(x - 1);%0A    %09%09Interval rightIvl = leftMap.get(x + 1);%0A    %09%09if(leftIvl == null && rightIvl == null)%7B%0A    %09%09%09Interval ivl = new Interval(x, x);%0A    %09%09%09leftMap.put(x, ivl);%0A    %09%09%09rightMap.put(x, ivl);%0A    %09%09%7Delse if(leftIvl != null && rightIvl == null)%7B%0A    %09%09%09leftIvl.end = x;%0A    %09%09%09rightMap.remove(x - 1);%0A    %09%09%09rightMap.put(x, leftIvl);%0A    %09%09%7Delse if(leftIvl == null && rightIvl != null)%7B%0A    %09%09%09rightIvl.start = x;%0A    %09%09%09leftMap.remove(x + 1);%0A    %09%09%09leftMap.put(x, rightIvl);%0A    %09%09%7Delse%7B%0A    %09%09%09Interval ivl = leftIvl;%0A    %09%09%09leftMap.remove(x + 1);%0A    %09%09%09rightMap.remove(x - 1);%0A    %09%09%09ivl.end = rightIvl.end;%0A    %09%09%09leftMap.put(ivl.start, ivl);%0A    %09%09%09rightMap.put(ivl.end, ivl);%0A    %09%09%7D%0A    %09%7D%0A    %09int maxlength = 0;%0A    %09for(Interval ivl : leftMap.values())%7B%0A    %09%09int length = ivl.end - ivl.start + 1;%0A    %09%09if(length %3E maxlength)%7B%0A    %09%09%09maxlength = length;%0A    %09%09%7D%0A    %09%7D%0A    %09return maxlength;%0A    %7D%0A%09%0A%09public static void main(String%5B%5D args)%7B%0A%09%09System.err.println(new Solution().longestConsecutive(new int%5B%5D%7B2147483646,-2147483647,0,2,2147483644,-2147483645,2147483645%7D));%0A%09%7D%0A%7D%0A

Add java solution for 128. Longest Consecutive Sequence