I just did the Amazon OA yesterday (10/9/2026). One coding question and one AI Debug.
Coding question:
Question 1 — Maximize Shipment Order
You're working in Amazon's logistics optimization team, where shipments are processed in order before dispatch.
You are given an integer windowSize and an array shipmentOrder of length n, which is a permutation containing each integer from 1 to n exactly once.
You are allowed to perform the following operation exactly once:
Choose a starting position i such that 1 ≤ i ≤ (n − windowSize + 1).
Consider the contiguous window of windowSize shipments starting at position i (from index i to i + windowSize − 1).
Reorder only this window in ascending numerical order, while keeping all other positions unchanged.
After performing this operation exactly once, the shipment order is finalized.
Your objective is to determine the lexicographically largest shipment order that can be obtained.
Note
Given two arrays A and B of equal length, A is lexicographically larger than B if at the first index where they differ, A has the larger value.
The reordering operation must be applied exactly once on shipmentOrder.
If the selected window is already in ascending order, reordering it leaves the array unchanged. Choosing an already-sorted window is valid, which is optimal if reordering any other window would make the array lexicographically smaller.
1-based indexing is used throughout the problem description.
Example
n = 5
shipmentOrder = [5, 1, 4, 3, 2]
windowSize = 3
Possible operations (1-indexed windows of length 3):
Choose i = 1:
Sort [5, 1, 4] → [1, 4, 5]
shipmentOrder = [1, 4, 5, 3, 2]
Choose i = 2:
Sort [1, 4, 3] → [1, 3, 4]
shipmentOrder = [5, 1, 3, 4, 2]
Choose i = 3:
Sort [4, 3, 2] → [2, 3, 4]
shipmentOrder = [5, 1, 2, 3, 4]
Comparing the achievable orders, the lexicographically largest result is: [5, 1, 3, 4, 2]
Function Description
Complete the function maximizeShipmentOrder in the editor below.
maximizeShipmentOrder takes the following arguments:
int shipmentOrder[n]: an array of integers representing shipment order
int windowSize: an integer representing the window size
Returns
int[n]: an array of integers representing the lexicographically largest shipment order achievable.
Constraints
1 ≤ windowSize ≤ n ≤ 2 * 10^5
1 ≤ shipmentOrder[i] ≤ n
shipmentOrder is a permutation of integers from 1 to n.
AI Debug:
This was mentioned on the forum before, it's something like Jira. The bug is that creating an Issue and a sub-issue is broken.
Discussion
Loading comments…