Reported October 2026
Amazonsorting

Maximize Center A Package Benefit

Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Amazon OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt on this Amazon OA, reported in October 2026, is reading it like a hard optimization problem. It isn't. The statement hands you the allocation rules, so the job is to simulate them exactly. For each linked pair, A takes the package with the larger A-benefit. Everything else gets sorted by combined benefit, and A takes every other one starting with the first. You'll sort, then alternate. If you blank on the tie-break or the indexing, StealthCoder is the invisible safety net running during the live assessment.

The problem

Two distribution centers, A and B, must allocate n packages. Package i is worth benefitA[i] to Center A and benefitB[i] to Center B.
The array linkedPairs contains disjoint pairs [x, y]. For each linked pair, exactly one package goes to A and the other goes to B; A receives whichever of the two packages has the larger A-benefit. Packages that do not appear in any linked pair are independent.
Order the independent packages by decreasing benefitA[i] + benefitB[i], breaking a tie by smaller package index. Center A receives the first independent package in that order and then every other package; Center B receives the remaining independent packages.

Examples
Example 1
benefitA = [8,3,7,4]
benefitB = [1,9,2,6]
linkedPairs = [[0,1]]
return = 12
From linked pair [0,1], A takes package 0 for benefit 8. Independent packages 2 and 3 have combined benefits 9 and 10, so their order is 3,2. A receives package 3 for another 4, giving 12.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The pattern is sorting plus simulation. First, mark every index that appears in a linked pair. For each pair [x, y], add max(benefitA[x], benefitA[y]) to the total. Then collect the unmarked indices and sort them by benefitA[i] + benefitB[i] descending, with smaller index winning ties. Walk the sorted list and add benefitA[i] for positions 0, 2, 4 and so on. Check it against Example 1: pair [0,1] gives 8, sorted independents are 3 then 2, and A takes package 3 for 4, so the total is 12. The common pitfalls are adding independent packages to the pair logic, forgetting the tie-break, and taking odd positions instead of even ones. Also don't pick by benefitB inside a pair. The rule only compares A-benefits. If you freeze mid-assessment, StealthCoder can hand you the sort comparator and the loop while you keep typing.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Maximize Center A Package Benefit cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Amazon's OA.

Amazon reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Maximize Center A Package Benefit FAQ

How hard is this Amazon OA problem really?+

Easy to medium. There's no search or DP. The difficulty is reading the rules carefully and implementing them without off-by-one errors. If you can sort with a custom comparator and loop with a step of two, you can solve it.

What's the trick to Maximize Center A Package Benefit?+

Treat it as a pure simulation. Pairs contribute the larger A-benefit. Independent packages are sorted by combined benefit descending, ties by smaller index, and A takes positions 0, 2, 4 and so on. Nothing needs to be optimized beyond following the stated order.

What's the most common mistake?+

Mixing up the two groups. People forget to exclude paired packages from the independent list, or they sort by benefitA alone instead of the sum. Another miss is skipping the index tie-break, which breaks tests with equal sums.

What time complexity should I aim for?+

O(n log n), dominated by sorting the independent packages. Marking paired indices and summing pair maxima is linear. A hash set or boolean array for marking is fine, and extra space is O(n).

How do I prepare in 48 hours?+

Practice custom-comparator sorts in your language, including tie-breaks on index. Then hand-trace Example 1 to confirm 12. Write a couple of edge cases yourself: no pairs, all paired, and one independent package. That covers most of what this problem tests.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Amazon.

OA at Amazon?
Invisible during screen share
Get it