Given a linked list. Does it contain a cycle?
Definition of a single linked list:
Implement a function hasCycle that returns 1 if linked list contains a cycle and 0 otherwise. It is forbidden to change the values of the list elements.
Function hasCycle returns 0 because this linked list does not contain a cycle.
Function hasCycle returns 1 because this linked list contains a cycle.