How to detect loop in linked list.
Given a linked list, determine if it has a cycle or loop in it.
For example:
In the below example, the last node (whose value is 9) points to node whose value is 5. The last node of a linked list does not points to a null. It has a cycle.