Reorder 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 singly linked list L0 -> L1 -> ... -> Ln-1 -> Ln. Rearrange its nodes into the order L0 -> Ln -> L1 -> Ln-1 -> L2 -> Ln-2 -> ..., alternating between the front and the back until every node is placed.
Rearrange the nodes themselves rather than rewriting values. Unlike the classic version that returns nothing, here you must **return the head** of the reordered list (which is still the original first node) so the grader can read it.
Aim for O(n) time and O(1) extra space.
Examples
Constraints
- 1 <= number of nodes <= 5 * 10^4
- 1 <= 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.