Given a linked list such that it's edges are numbered as a1, a2, .... an.
The linked list is as follows.

Then detect if there is a cycle in the linked list or not.
Expected time complexity ; O(n)
Expected space complexity: O(1).
@anomekumar08 please assign this issue to me under Hacktoberfest 22.