Interleave Route Stops From Both Ends of a Linked List
Last updated: November 29, 2026
Quick Overview
Given a singly linked list of stops L0 -> L1 -> ... -> Ln, reorder it in place to L0 -> Ln -> L1 -> Ln-1 -> ..., for example to alternate a courier between nearby and far drop-offs. Return nothing; modify the list.
Uber
November 29, 20260
0
0 solved
Given a singly linked list of stops L0 -> L1 -> ... -> Ln, reorder it in place to L0 -> Ln -> L1 -> Ln-1 -> ..., for example to alternate a courier between nearby and far drop-offs. Return nothing; modify the list.
An Uber technical screen linked list problem that combines three primitives: find the middle, reverse a list, and merge two lists. The interviewer checks that you can compose them without an extra array and without creating a cycle.
What the Interviewer Expects
- Finds the middle with slow and fast pointers
- Splits the list and terminates the first half
- Reverses the second half in place
- Merges alternately
- Discusses the O(n) array baseline and why O(1) space is better
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you undo this reordering?
- What if you need L0 -> Ln -> Ln-1 -> L1 instead?
- How would you do this on a doubly linked list?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: head of a singly linked list, possibly empty. Output: none, the list is rewired in place. O(1) extra space required, so copying nodes into an array is only a baseline....
High-Level Design
Step 1: slow and fast pointers stop slow at the end of the first half (for even lengths, the first middle). Step 2: cut after slow and reverse the second half. Step 3: merge, taking one node from the ...