Grokking the Coding Interview: Patterns for Coding Questions
0% completed
Introduction to Fast & Slow Pointers Pattern
The Fast & Slow pointer approach, also known as the Hare & Tortoise algorithm, is a pointer algorithm that uses two pointers which move through the array (or sequence/LinkedList) at different speeds. By moving at different speeds (say, in a cyclic LinkedList), the algorithm proves that the two pointers are bound to meet. The fast pointer should catch the slow pointer once both the pointers are in a cyclic loop.
.....
.....
.....
Like the course? Get enrolled and start learning!
A
Anamitra Datta
· 3 years ago
I would also recommend https://leetcode.com/problems/find-the-duplicate-number/ as good problem to practice Fast and Slow pointers (Floyd's cycle detection) since its not listed in this section