📚 PracticeEasyAlgorithm ProblemCoding Ready

Linked List Cycle

linked-listtwo-pointers
LeetCode #141
Updated Dec 20, 2025

Question

Given head, determine if the linked list has a cycle in it.

LeetCode: Linked List Cycle

Example:

Input: head = [3,2,0,-4], pos = 1 (cycle back to node with value 2)
Output: true

Hints

Hint 1

Think about using two pointers moving at different speeds. What happens if there's a cycle?

Hint 2

Use a slow pointer (moves 1 step) and a fast pointer (moves 2 steps). They will eventually meet if there's a cycle.

Hint 3

If the fast pointer reaches null, there's no cycle. If it catches up to slow, there is a cycle.


Your Solution

python
Auto-saves every 30s

Try solving the problem first before viewing the solution


0:00time spent