Middle of the List
EasyLinked List
Decode it first. Clues, constraints, pattern and plan before any code.Given the head of a non-empty linked list, return the middle node. If there are two middle nodes (an even count), return the second one. Aim for a single pass.
The tests show the list from the node you return onwards.
1 -> 2 -> 3 -> 4 -> 5 → 3 -> 4 -> 5
1 -> 2 -> 3 -> 4 -> 5 -> 6 → 4 -> 5 -> 6Constraints
1 <= number of nodes <= 1001 <= Node.val <= 100