Reorder a Pick List by Alternating First and Last Items

Last updated: November 29, 2026

Quick Overview

Given a singly linked pick list L0, L1, ..., Ln, reorder it in place to L0, Ln, L1, Ln-1, L2, ... so a picker alternates between the two ends of an aisle. Do not create new nodes.

Amazon
Coding & Algorithms
Software Engineer
Amazon
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Given a singly linked pick list L0, L1, ..., Ln, reorder it in place to L0, Ln, L1, Ln-1, L2, ... so a picker alternates between the two ends of an aisle. Do not create new nodes.

This tests whether a candidate can compose three standard list operations under pressure, a pattern Amazon onsite coding rounds like. The interviewer checks decomposition, clean helper functions and correct termination of the merged list.

What the Interviewer Expects
  • Find the middle with fast and slow pointers
  • Cut the list and reverse the second half in place
  • Interleave the halves, terminating with None
  • O(n) time and O(1) extra space
  • Explain why the first half is the same length or one longer
Key Topics to Cover
linked lists
fast and slow pointers
in-place reversal
list merging
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you undo the reordering?
  • What if you could use O(n) memory: what is the simplest approach?
  • How would you reorder into L0, Ln, Ln-1, L1, L2, ... instead?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input is the head of a singly linked list, possibly empty. Rearrange the existing nodes (values must not be copied around) so the order alternates first, last, second, second last, and so on. Return n...

High-Level Design

Three steps. First, find the end of the first half with slow and fast pointers. Second, detach the second half and reverse it. Third, weave: take one node from the first half, then one from the revers...


Submit Your Answer
Markdown supported