Hardware interview practice
Find the middle node
Return the middle node of a singly linked list. For an even-length list, return the second of the two middle nodes.
Reviewed example
Work through one case
Input
head = 1 -> 2 -> 3 -> 4 -> nullExpected output
node with value 3With an even number of nodes, the fast pointer reaches null after slow advances to the second middle node.
What to cover
Requirements
- Use one traversal.
- Use constant extra space.
- Return null for an empty list.
