public static int longestConsecutive(int[] num) {
		if (num.length == 0)
			return 0;
		// LongestConsecutiveSequence instance = new
		// LongestConsecutiveSequence();
		// Queue<Integer> queue = new
		// PriorityQueue<Integer>(num.length+1,instance.new MyComparator());
		Queue<Integer> queue = new PriorityQueue<Integer>();

		for (int i : num)
			queue.add(i);

		int maxLength = 1;
		int tempLength = 1;
		int prev = queue.poll();
		int i = 0;
		while (!queue.isEmpty()) {
			i = queue.poll();
			if (i == prev) {
				prev = i;
				continue;
			} else if (i == prev + 1) {
				tempLength++;
				maxLength = tempLength > maxLength ? tempLength : maxLength;
				prev = i;
			} else {
				tempLength = 1;
				prev = i;
			}	
		}
		return maxLength;
	}