def maximizeShipmentOrder(shipmentOrder: list[int], windowSize: int) -> list[int]:
The round: the coding half of Amazon's online assessment (40 minutes in one report), next to an AI-assisted debugging task. Two candidates reported it, on September 30 and October 9, 2026. The second posted the full prompt, "Maximize Shipment Order"; the first describes the same task and calls it a hard DP problem. The example and constraints below are as reported; the prose is paraphrased.
Problem
shipmentOrder is a permutation of 1..n and windowSize is an integer. You must apply this operation exactly once: choose a start i with 1 ≤ i ≤ n - windowSize + 1 (1-based) and sort the windowSize shipments from position i to i + windowSize - 1 in ascending order, leaving every other position as it is. Return the lexicographically largest order you can end up with. (Array A is lexicographically larger than B if, at the first index where they differ, A has the larger value.)
The operation is mandatory, but choosing a window that is already sorted leaves the array unchanged, and that is the right choice when sorting any other window would make the order smaller.
def maximizeShipmentOrder(shipmentOrder: list[int], windowSize: int) -> list[int]: ...
Constraints
1 ≤ windowSize ≤ n ≤ 2 * 10^5shipmentOrder is a permutation of the integers 1 to n.Example
shipmentOrder = [5, 1, 4, 3, 2], windowSize = 3
i = 1: sort [5, 1, 4] -> [1, 4, 5, 3, 2]
i = 2: sort [1, 4, 3] -> [5, 1, 3, 4, 2]
i = 3: sort [4, 3, 2] -> [5, 1, 2, 3, 4]
Output: [5, 1, 3, 4, 2]
One candidate had seen it before and solved it smoothly, but thought few people could do it under exam conditions without that; their OA's second task was an AI-assisted object-oriented debugging exercise with six tests, five of which they passed. The other candidate's OA paired it with an AI debugging task on a Jira-like app.
Also reported as Sort Packages Within a Window
The round: the coding half of Amazon's online assessment (40 minutes in one report), next to an AI-assisted debugging task. Two candidates reported it, on September 30 and October 9, 2026. The second posted the full prompt, "Maximize Shipment Order"; the first describes the same task and calls it a hard DP problem. The example and constraints below are as reported; the prose is paraphrased.
Problem
shipmentOrder is a permutation of 1..n and windowSize is an integer. You must apply this operation exactly once: choose a start i with 1 ≤ i ≤ n - windowSize + 1 (1-based) and sort the windowSize shipments from position i to i + windowSize - 1 in ascending order, leaving every other position as it is. Return the lexicographically largest order you can end up with. (Array A is lexicographically larger than B if, at the first index where they differ, A has the larger value.)
The operation is mandatory, but choosing a window that is already sorted leaves the array unchanged, and that is the right choice when sorting any other window would make the order smaller.
def maximizeShipmentOrder(shipmentOrder: list[int], windowSize: int) -> list[int]: ...
Constraints
1 ≤ windowSize ≤ n ≤ 2 * 10^5shipmentOrder is a permutation of the integers 1 to n.Example
shipmentOrder = [5, 1, 4, 3, 2], windowSize = 3
i = 1: sort [5, 1, 4] -> [1, 4, 5, 3, 2]
i = 2: sort [1, 4, 3] -> [5, 1, 3, 4, 2]
i = 3: sort [4, 3, 2] -> [5, 1, 2, 3, 4]
Output: [5, 1, 3, 4, 2]
What candidates report: The full prompt was posted in October 2026. A candidate nine days earlier calls it a hard DP problem and says they solved it smoothly only because they had seen it before.
Our note (not from the reports): Sorting a window never makes the order larger. If some window is already sorted, return the input unchanged; otherwise choose the window whose first changed position is furthest right, and the earliest such window on a tie.
Send them this page. It is free to read, no account needed.
What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 57 Amazon questions, refreshed monthly from new candidate reports.