easy
Middle of the Linked List
Return the middle node of a singly linked list. If the list has an even number of nodes, return the second of the two middle nodes.
Constraints
- 1 ≤ number of nodes ≤ 100
Examples
in: head = 1 → 2 → 3 → 4 → 5
out: node 3
in: head = 1 → 2 → 3 → 4 → 5 → 6
out: node 4
Code it yourself
Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?
Choose an approach to check your pattern recognition, or reveal the discussion when you need help.