public ListNode detectCycle(ListNode head) {
			if (head == null || head.next == null) {
				return null;
			}
			ListNode temp = new ListNode(-1);
			temp.next = head;
			head = temp;
			ListNode fast = head;
			ListNode slow = head;
			while (true) {
				for (int i = 0; i < 2; ++i) {
					fast = fast.next;
					if (fast == null) {
						return null;
					}
					if (fast == head) {
						return head;
					}
				}
				slow = slow.next;
				if (fast == slow) {
					fast = head;
					while (fast != slow) {
						fast = fast.next;
						slow = slow.next;
					}
					return fast;
				}
			}
		}