876. Middle of the Linked List
Practice Middle of the Linked List for free on NudgeCode: Easy, Linked List pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Return the middle node of a non-empty linked list. When the list has an even number of nodes there are two middles; return the second one. The answer is the node itself, so the expected output is the list starting at that node.
Example
head = [1,2,3,4,5] -> [3,4,5]
head = [1,2,3,4,5,6] -> [4,5,6]
Constraints
- 1 <= length of the list <= 100
- 1 <= Node.val <= 100