Check if a given linked list has cycles. Try to achieve O(n) runtime with a space complexity of O(1).
If there is a cycle, return

Examples:

`true`

otherwise return `false`

. Consider empty lists as non cyclic.
Examples:

`1->2->3->4->1 ==> true`

`1->2->3->4 ==> false`

Need a **hand?** Try out these hints, one at a time.

The key here is to use **two temporary pointers**, one of them traverses the list one node at a time and the other one traverses the list two nodes at a time. If the pointers collide, there is a loop.

Try the Floyd Cycle Finding Algorithm, also known as the 'Tortoise & Hare Algorithm'.
In this approach, you maintain two pointers -

`'slow'`

& `'fast'`

where `slow`

moves one node at a time and `fast`

moves two nodes at a time. If there is a cycle, these two pointers will inevitably meet! Seriously, they will.
public Boolean isCyclic(ListNode head) { }

**C**

**Java**

**Python**