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 true otherwise return false. Empty lists should be considered non-cyclic.
Examples: 1->2->3->4->1 ==> true 1->2->3->4 ==> false
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!