Finding a cycle in a linked list
There is a popular task at software developer job interviews: having a singly linked list, write a piece of code which tells if the list has a cycle.
In a linked list, each element is a structure which contains the value of an element and the link to the next element. The next-link of the last element has a special value which marks the end (usually,
null). If a list has a cycle, the last element points to some element inside the list.