Given a singly-linked list, implement a method to check if the list has cycles. The space complexity can be **O(n)**.
If there is a cycle, return

Examples:

`true`

otherwise return `false`

. Empty lists should be considered 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 check the uniqueness of the nodes in the list. One way to achieve it would be to use a

`Hashtable`

. Since the problem mentions that the space complexity can be O(n), you're good with the extra space this would take!
Save the visited node and its value in the

`Hashtable`

. While traversing through the list if current node is in the hashtable, there is a loop.
public Boolean isCyclic(ListNode head) { }

**C**

**Java**

**Python**