public int longestConsecutive_lint(int[] num) {
        // write you code here
        int res = 0;
        HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
        for (int i : num) {
            map.put(i, 0);
        }
        for (int i : num) {
            if (map.get(i) == 1)
                continue;
            int right = i + 1;
            int localmax = 1;
            while (map.containsKey(right)) {
                map.put(right, 1);
                right++;
                localmax++;
            }
            int left = i - 1;
            while (map.containsKey(left)) {
                map.put(left, 1);
                left--;
                localmax++;
            }
            res = Math.max(res, localmax);
        }

        return res;
    }