Search for a command to run...
Use the fast and slow pointer technique to find the middle in one pass
Initialization
slow and fast pointers set to head (1).
Tortoise and Hare
1class Solution {2 middleOfLinkedList(head) {3 let slow = head;4 let fast = head;5 6 while (fast !== null && fast.next !== null) {7 slow = slow.next;8 fast = fast.next.next;9 }10 11 return slow;//slow: 1fast: 112 }13}