Back to blog
Mar 17, 2024
1 min read

Algorithms: Fast and Slow Pointers

Two pointers in the same direction at two different speeds

Fast and Slow Pointers

The fast and slow pointer approach aka hare and tortoise algorithm, is a two pointer pattern with one pointer moving through the array at a different speed.

Problems of the sort would be where loops are detected in a linked list or an array. Also for problems where you need to find the position of a certain element or the overall length of a linked list.