Reorder List

Python data engineering interview problem. Difficulty: intermediate. Pattern: Linked Lists. About 14 minutes. Part of the Pro drill bank.

Reorder to L0, Ln, L1, Ln-1, ... Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.

A delivery route is stored from its first stop to its last, but the new route should alternate from the front and back. Reorder the values as L0, Ln, L1, Ln-1 and continue inward. Return the reordered list in that exact pattern. Write reorder_list(values: list) -> list. [1, 2, 3, 4] becomes [1, 4, 2, 3]. The starter file already has the function name and harness print lines. Keep them and fill only the function body.

Requirements

  • Take one value from the front, then one from the back.
  • Continue until every value is used once.
  • Keep the relative inward order of both sides.

Constraints

  • The input is a list representation of a linked list.
  • The return type is a list with the same length as the input.

Examples

Input: reorder_list([1, 2, 3, 4]) Output: [1, 4, 2, 3] Weave front and reversed back.

Topics: lakebench, python, reorder, list api.

More Python interview questions · All interview problems · Learn data engineering

intermediate

Reorder List

Interview-style drill: Reorder to L0, Ln, L1, Ln-1, ...

Implement `reorder_list(values: list) -> list` reordering in-place style to L0, Ln, L1, Ln-1, ... Example: `[1, 2, 3, 4]` → `[1, 4, 2, 3]`. Keep the harness.