Middle of a linked list
Problem Find the middle node of the linked list.
Follow up - How will you get it in first pass.
Solution Method 1 - Get the length and travel to middle
Traverse the whole linked list and count the no. of nodes. Now traverse the list again till count/2 and return the node at count/2.
Method 2 - Uses one slow pointer and one fast pointer
Traverse linked list using two pointers.
[Read More]