Middle of the Linked List Visualizer & Step-by-Step Algorithm Solution

Find the middle node of a singly linked list using fast and slow pointers.

Category: linked-list | Difficulty: Easy

Tags: Linked List, Two Pointers, Fast & Slow Pointers

Middle of the Linked List

1
2
3
4
5
100%
state
slowN/A
fastN/A
Initialization
1/11
Explanation

Initializing middleNode function with linked list.

Source Code
1function middleNode(head) {
2 let slow = head;
3 let fast = head;
4 while (fast && fast.next) {
5 slow = slow.next;
6 fast = fast.next.next;
7 }
8 return slow;
9}