Find Middle of Linked List

00:00
EasyLinked ListTwo PointersFast and Slow
TCSInfosys

Return the middle node of a singly linked list. For even length, return the second middle node.

Examples

Input → 1
Output → 2->3->4->5 -> Node 3
Input → 1
Output → 2->3->4->5->6 -> Node 4
Input → [1]
Output → Node 1
Input → 1
Output → 2 -> Node 2