FastPrepMaximize Shipment Order by Sorting One Window
Problems/Maximize Shipment Order by Sorting One Window

Maximize Shipment Order by Sorting One Window

Amazon logoAmazon● HardFULLTIMENEW GRADINTERNOA

Updated Nov 2026

QuestionExamples

Problem statement

Source note: Reported in an Amazon full-time and new grad online assessment. The report fully gives the fixed window, the reorder in ascending order, the rule that each item is used exactly once, the input as a permutation, and the lexicographic goal. We changed only the function signature to be simple. Our version is about 99% the same as the reported question.

Special thanks: 🌷 A special thank you to our lovely, amazing frenz for sharing that this question appeared again on October 27, 2026, November 15, 2026, November 20, 2026, November 22, 2026, and November 25, 2026 and helping keep Last Seen up to date! ( ˘͈ ᵕ ˘͈♡) 💜

shipmentOrder has length n and is a permutation of 1..n. Choose exactly one contiguous window of length windowSize, sort that window in ascending order, and return the lexicographically largest complete array obtainable.

Positions are 1-based. A window that starts at position i covers positions i through i + windowSize - 1, so 1 <= i <= n - windowSize + 1.

One array is lexicographically larger than another array of the same length when it has the larger value at the first position where the two differ.

The problem statement continues
Pro

Examples

Example 1

shipmentOrder = [5,1,4,3,2]windowSize = 3return = [5,1,3,4,2]

With 1-based positions there are three windows of length 3. Starting at i = 1 gives [1,4,5,3,2], starting at i = 2 gives [5,1,3,4,2], and starting at i = 3 gives [5,1,2,3,4]. The window that starts at i = 2 (positions 2 through 4) keeps 5, 1 at the front and then has the larger third value, so it is the answer.

02 · Example 2
2 original screenshots from the interview report
Pro
FastPrep Pro
Reported in 1 Amazon interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 1 more worked example, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week

More Amazon Online Assessment questions

  • Lexicographically Largest IdentifierOA · Seen Nov 2026
  • Top K Frequent ElementsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Fill One Exact-Length Binary WindowOA · Seen Nov 2026
  • Minimum Grid InconvenienceOA · Seen Nov 2026
  • Maximize K-Element AND with an Increment BudgetOA · Seen Nov 2026
  • Task SchedulerOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Get Smallest Base SegmentOA · Seen Nov 2026
  • Minimum Cost of Left and Right PropagationOA · Seen Nov 2026
  • Maximum Equal-Bit Pairs in a SubsequenceOA · Seen Nov 2026
  • First Non-Repeating CharacterOA · ONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Most Segments That Sort the ArrayRippling · OARippling interview questions
  • Most Items Within Budget from a Start IndexHudson River Trading · OAHudson River Trading interview questions
  • Power Update After K-th Largest InsertionGoogle · OAGoogle interview questions
  • Alternating Jumps to the Last IndexExpedia · OAExpedia interview questions
  • Count Decreasing TripletsAirbnb · OAAirbnb interview questions
  • Rebuild the Queue From Taller-in-Front CountsAdobe · PHONE SCREENAdobe interview questions
  • Implement QuicksortJP Morgan Chase · ONSITE INTERVIEWJP Morgan Chase interview questions
  • Hard Disk Clustering CostConfluent · OAConfluent interview questions
  • Sliding Window MedianAuxoAI · OA
  • Delete and Freeze GameRubrik · OARubrik interview questions

Interview reports that mention this question

  • Amazon New Grad OA Problems: Every Task We Have (Part 3 of 5)
  • Amazon OA · November 2026

Amazon interview experiences

  • Amazon Experienced SDE Onsite Questions: 1 Experience
  • Amazon SDE Onsite Interview Questions: 9 Experiences
  • Amazon SDE II and L5 FDE Interview Questions: 4 Experiences
  • Amazon Full-Time OA Problems, Earlier Reports (Part 5 of 5)
See Amazon hiring insights
CodePython 3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import heapq
from collections import defaultdict
 
class Solution:
def solve(self, values, queries):
# Build the adjacency structure
n = len(values)
graph = defaultdict(list)
for u, v in queries:
graph[u].append(v)
 
best = [float("inf")] * n
heap = [(0, 0)]
while heap:
cost, node = heapq.heappop(heap)
if cost > best[node]:
continue
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Amazon interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 1 more worked example, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week