public int getLongestConsecutive(int[] num) {
		Set<Integer> s = new HashSet<Integer>();
		int max = 1, count;
		for (int i : num)
			s.add(i);

		for (int e : num) {
			int left = e - 1;
			int right = e + 1;
			count = 1;

			while (s.contains(left)) {
				count++;
				s.remove(left);// has to remove, in case of duplicated ele
				left--;
			}
			while (s.contains(right)) {
				count++;
				s.remove(right);// has to remove, in case of duplicated ele
				right++;
			}
			max = Math.max(max, count);

		}
		return max;
	}