Search⌘ K
AI Features

Linked List Cycle II

Explore how to detect the node where a cycle begins in a linked list. Understand the problem constraints and learn an efficient approach that runs in linear time and constant space. This lesson helps you apply coding interview techniques to solve linked list cycle challenges effectively.

Statement

Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null.

A cycle exists in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos denotes the node’s index to which the tail’s next pointer is connected.

Constraints:

  • The number of the nodes in the list is in the range [0,104][0, 10^4] ...