public boolean hasCycle(Node head){
        if (head == null) {
            return false;
        }
        Node slow = head;
        Node fast = head.next;
        while (fast != null) {
            if (slow == fast || fast.next == slow) {
                return true;
            }
            slow = slow.next;
            if (fast.next != null) {
                fast = fast.next.next;
            } else {
                break;
            }
        }
        return false;
    }
Date 04/17/2016
@author tusroy

Given a linked list, determine if it has a cycle in it.

Time complexity O(n)
Space complexity O(1)

https://leetcode.com/problems/linked-list-cycle/
src/com/interview/linklist/LoopInLinkList.java