All Topics

Linked Lists

Pointer manipulation, in-place reversal, and fast-slow techniques

0/40 solved

Fast & Slow Pointers

Detect cycles, find midpoints, and identify patterns with two-speed traversal

O(n) O(1)

Approach

Use two pointers moving at different speeds. The fast pointer moves twice as fast as the slow pointer. If there's a cycle, they'll eventually meet. For middle finding, when the fast pointer reaches the end, the slow pointer is at the middle.

How to Recognize

1

Problem involves cycle detection in a linked list

2

Need to find the middle of a linked list

3

Phrases like 'happy number', 'circular linked list'

4

Need to find the start of a cycle

Pro Tips

Fast moves 2 steps, slow moves 1 step — they meet inside a cycle if one exists

To find cycle start: after detection, reset one pointer to head and move both at speed 1

For finding middle: when fast reaches end, slow is at middle

8

Total

4

Easy

4

Medium

0

Hard

Time

O(n)

Space

O(1)