Back to DSA
Linked List Cycle
easyGiven the head of a singly linked list, determine whether the list contains a cycle. A cycle exists when following the links from some node eventually leads back to a previously visited node, forming a loop.
Examples
Example 1:
Input:
head = [5,8,2,-1], pos = 2Output:
true Example 2:
Input:
head = [4], pos = -1Output:
falseHints
1234567