Finding the middle of a Linked List
Sep 24, 2022
Hello guys, today we are going to discuss how to find the middle node of a linked list using the concept of slow and fast pointers.
So let’s start with the concept of slow and fast pointers.
Initially, both the pointers will point to the head of the linked list, then we start traversing the linked list node by node and change the slow pointer by one node and the fast pointer by two nodes. This traversal will eventually leave the slow pointer in the middle of the linked list when the fast pointer will reach the end.
The code for the abovementioned approach is given below:
Thanks 😃 for going through this article.