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
Problem | Topic | Platform |
---|---|---|
Linked List Cycle | Fast-Slow Pointers | Leetcode |
Linked List Cycle II | Fast-Slow Pointers | Leetcode |
Middle of the Linked List(Second Middle Node) | Fast-Slow Pointers | Leetcode |
Find the Duplicate Number | Fast-Slow Pointers | Leetcode |
Convert Sorted List to Binary Search Tree | Fast-Slow Pointers | Leetcode |
Rotate List | Fast-Slow Pointers | Leetcode |
Reorder List | Fast-Slow Pointers | Leetcode |