Coordinate Bounding Box
Reported by candidates from Upstart's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The data structure behind this Upstart OA, reported in July 2026, is barely a structure at all: four running variables and one pass over an array. Coordinate Bounding Box asks for [minX, minY, width, height] from a list of points. It's an easy array problem, and that's the trap. Easy questions get rushed, and rushed code misses empty input or negative coordinates. If you blank on the setup, StealthCoder sits invisibly on your screen as a safety net during the live OA and gives you the loop. Most people won't need it, but it's there.
The problem
Given a list of two-dimensional points (x, y), return [minX, minY, width, height], where width = maxX - minX and height = maxY - minY. Function boundingBox(points: int[][]) → int[] Examples Example 1 points = [[2,5],[-1,3],[4,9]] return = [-1,3,5,6] The minimum corner is (-1,3). The width is 4 - (-1) = 5, and the height is 9 - 3 = 6.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is a single scan. Track minX, maxX, minY, maxY. Initialize them from the first point, not from 0, because negative coordinates like the -1 in the example will break a zero default. Then update all four on each point and return [minX, minY, maxX - minX, maxY - minY]. That's O(n) time and O(1) space. Sorting works but costs O(n log n) for no gain. Common pitfalls: initializing mins to 0, swapping width and height, and returning maxX instead of the difference. Check the example by hand: min corner (-1,3), width 4 - (-1) = 5, height 9 - 3 = 6. Ask whether empty input can happen, since the problem text doesn't say. If you freeze mid-assessment, StealthCoder is the hedge that reads the prompt and hands you the loop, so you can verify it against the example.
If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.
You can drill Coordinate Bounding Box 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 StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass Upstart's OA.
Upstart 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.
Coordinate Bounding Box FAQ
How hard is Coordinate Bounding Box really?+
It's easy. One pass, four variables, no tricks beyond initialization. The risk isn't the algorithm, it's careless bugs like starting mins at 0 or mixing up width and height. Trace the sample input once and you're fine.
What's the trick to solving it fast?+
Initialize minX, maxX, minY, maxY from the first point, then loop through the rest updating each. Return [minX, minY, maxX - minX, maxY - minY]. No sorting, no extra data structures needed.
Should I sort the points?+
No. Sorting by x then separately by y costs O(n log n) and needs two orderings. A single linear scan gives the same answer in O(n) with constant space, and it's less code to get wrong.
What edge cases should I check?+
Negative coordinates, a single point (width and height both 0), and all points sharing an x or y value. Empty input isn't covered in the problem text, so handle it defensively or confirm the constraints if you can.
How do I prepare in 48 hours?+
Write this loop from memory twice, then do a few other array scans that track running min and max values. Practice initializing from the first element rather than a magic number. That habit covers most easy array questions on an OA.