public int longestConsecutive1(int[] num) {
		if (num.length <= 1)
			return num.length;
		int max = 1;
		boolean[] visited = new boolean[num.length];
		HashMap<Integer, Integer> maps = new HashMap<Integer, Integer>();
		for (int i = 0; i < num.length; i++) {
			maps.put(num[i], i);
		}
		for (int i = 0; i < num.length; i++) {
			if (visited[i])
				continue;
			int index = num[i] - 1;
			int len = 1;
			visited[i] = true;
			// contains n - 1
			while (maps.containsKey(index)) {
				len++;
				visited[maps.get(index)] = true;
				index--;
			}
			index = num[i] + 1;
			// contains n + 1
			while (maps.containsKey(index)) {
				visited[maps.get(index)] = true;
				index++;
				len++;
			}
			if (len > max)
				max = len;
		}
		return max;
	}