Choose Warehouse Location
Reported by candidates from Amazon's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Amazon's warehouse location problem showed up in August 2024 OAs and it's a logistics optimization question disguised as geometry. You're given coordinates or distances, and you need to pick a warehouse position that minimizes total delivery cost or distance to customers. This is a classic median/centroid problem, and the trick is recognizing that you don't brute-force every point. StealthCoder will catch the pattern if you freeze up on the math side of the optimization.
Pattern and pitfall
The core move is finding the optimal center point. For one dimension, the answer is the median of all customer positions. For two dimensions, it's trickier because the Euclidean median has no closed-form solution, so you either use the Weiszfeld algorithm, ternary search, or recognize that the problem constraints let you evaluate a discrete set of candidate points. The pitfall: candidates overthink and try to grid-search or use calculus when the problem actually wants you to identify that the answer sits at one of the given coordinates or at a weighted balance point. Amazon tests whether you know the geometric intuition, not just brute force. If you blank on the math during the live OA, StealthCoder supplies the exact approach without you having to derive it.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
You can drill Choose Warehouse Location 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. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Amazon's OA.
Amazon reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Choose Warehouse Location FAQ
Is this actually a median problem?+
Yes, in 1D it's exactly the median. In 2D, it's the Euclidean median, which is harder but often solvable via ternary search or by testing candidate points. Amazon usually constrains the problem so you can evaluate a finite set rather than compute calculus.
Do I need to know the Weiszfeld algorithm?+
Not if the constraints are small enough to brute-force. If n is under 10,000 and the grid is bounded, you can evaluate all points or use ternary search. Check the problem statement for hints on scale. Amazon rarely forces the full iterative algorithm.
What if the problem mentions weights or demand?+
Then it's a weighted median or weighted centroid problem. Find the point where cumulative weight splits evenly in 1D, or use a weighted Euclidean distance in 2D. The principle is the same: balance, not brute force.
How do I check if my answer is right?+
Calculate the total cost (sum of distances or weighted distances) for your chosen warehouse location. Compare it against a few other candidate points. If yours is the lowest and the logic is sound, you're good.
Is this still asked in 2024 OAs?+
Yes. Amazon logistics problems remain common in their OAs because they test geometric intuition and optimization thinking. This specific variant or a variation shows up regularly. Expect it.