Solution: Linked List Cycle
Let’s solve the Linked List Cycle problem using the Fast and Slow Pointers pattern.
Statement
Check whether or not a linked list contains a cycle. If a cycle exists, return TRUE. Otherwise, return FALSE. The cycle means that at least one node can be reached again by traversing the next
pointer.
Constraints:
Let n
be the number of nodes in a linked list.
-
n
-
Node.data
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.