dsa · easy
Middle of Linked List
GreyOrangeLinked ListTwo PointersFoundation
head is a list of node values. Return the value of the **middle** node (the second middle if even length). Empty list → null.
Arguments
head— the linked list, given as a Python list of node values
**Example:** [1,2,3,4,5] → 3. [1,2,3,4] → 3.
Constraints
0 <= length <= 100 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: [1,2,3,4,5] Expected: 3
Example 2
Input: [1,2,3,4] Expected: 3