Skip to content
Ultimate Algorithm

Fast-Slow Pointers

These pointers move at different speeds, typically in linked lists. The slow pointer moves one step at a time, while the fast pointer moves two steps at a time. This technique is useful in problems involving cycles, such as detecting a cycle in a linked list or finding the middle of a linked list. If a cycle exists, the fast pointer will eventually catch up to the slow pointer.

This method is also known as “Hare and Tortoise” Technique for referencing fast pointer as Hare and slow pointer as Tortoise

ProblemTopicPlatform
Linked List CycleFast-Slow PointersLeetcode
Linked List Cycle IIFast-Slow PointersLeetcode
Find the Duplicate NumberFast-Slow PointersLeetcode
Convert Sorted List to Binary Search TreeFast-Slow PointersLeetcode
Rotate ListFast-Slow PointersLeetcode
Reorder ListFast-Slow PointersLeetcode