Middle of the Linked List
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given the head of a non-empty singly linked list. Return the node that sits in the middle of the list.
When the list has an odd number of nodes there is exactly one middle node. When the length is even there are two candidates; return the **second** of them (the one closer to the tail).
The grader reads the list starting from the node you return, so returning the correct node yields the tail portion of the original list from the middle onward. Aim for a single pass and O(1) extra space.
Examples
Constraints
- 1 <= number of nodes <= 1000
- -1000 <= Node.val <= 1000
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.