Fast and Slow Pointers
Karambir Sharma
Full Stack Developer at Allstate | Competitive Programming | System Design | DataStructure and Algo | Azure | Azure Cloud Certified| AWS
I will cover all the LeetCode Patterns for coding Interviews mentioned by a few folks. I'll write the code using C#. Today's post is related to Slow and Fast pointer LeetCode Patterns for Coding Interviews.
?
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. This approach is quite useful when dealing with cyclic?LinkedLists?or arrays.
?
Related Problems
1. Finding a?cycle?in a LinkedList
2. Find Middle Element
Creating Linked List.
internal class SlowandFastPointer
Main Method.