Reported September 2026
Wayvegreedy

Non-Maximum Suppression

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

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

Wayve's September 2026 OA boils down to one thing: sort, then filter with a geometry check. Non-Maximum Suppression sounds like a computer vision topic, but it's a greedy loop with integer math. Sort boxes by confidence descending, break ties by smaller index, and keep a box only if its IoU with every kept box stays at or under thresholdPercent / 100. Up to 5000 boxes means O(n^2) is fine. The trap is the comparison, not the idea. If you blank on the details, StealthCoder is the invisible hedge running during the live OA.

The problem

Each detection box is [x1, y1, x2, y2, confidence], where the lower-left corner is inclusive and the upper-right coordinate defines the geometric boundary. Process boxes by descending confidence, breaking ties by smaller original index.
Keep a box unless its intersection-over-union with any already kept box is strictly greater than thresholdPercent / 100. Return kept original indices in selection order. Use exact integer cross-multiplication when comparing the ratio.

Function
nonMaximumSuppression(boxes: int[][], thresholdPercent: int) → int[]

Examples
Example 1
boxes = [[0,0,10,10,90],[1,1,9,9,80],[20,20,30,30,70]]
thresholdPercent = 50
return = [0,2]
Box 1 overlaps the higher-confidence box 0 above the threshold, while box 2 is separate.
Example 2
boxes = [[0,0,2,2,5],[1,0,3,2,5]]
thresholdPercent = 40
return = [0,1]
Equal confidence selects index 0 first; the boxes overlap by one third, which is not greater than 40 percent.

Constraints
0 <= boxes.length <= 5000
x1 < x2 and y1 < y2
0 <= confidence <= 1000000
0 <= thresholdPercent <= 100

Reported by candidates. Source: FastPrep

Pattern and pitfall

The pattern is greedy plus sorting. Build an index array, sort by confidence descending then index ascending, then walk it. For each candidate, compare against every box already kept. Compute intersection width as min(x2) - max(x1), height the same way, and clamp both at zero. Area of union is areaA + areaB - intersection. The problem demands exact integer cross-multiplication, so never use floats. Keep the box unless intersection * 100 > thresholdPercent * union. Strictly greater means equality keeps the box, and Example 2 tests exactly that: one third overlap against 40 percent. Common pitfalls are using >= by mistake, forgetting the tie-break, and returning sorted indices instead of selection order. Touching edges give zero intersection, so clamp. If the details slip under pressure, StealthCoder can show a clean solution on screen during the live OA without the proctor seeing it.

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 Non-Maximum Suppression 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 Wayve's OA.

Wayve 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.

Non-Maximum Suppression FAQ

What's the trick in the Wayve Non-Maximum Suppression question?+

It's a greedy filter. Sort by confidence descending with index as the tie-break, then keep each box only if its IoU with all kept boxes is not strictly above the threshold. The real work is getting the intersection and union math right with integers.

How do I compare IoU without floating point?+

Cross-multiply. IoU > t/100 becomes intersection * 100 > t * union. Both sides are integers, so there's no rounding error. Coordinates are bounded by the constraints, but use a 64-bit type in languages where overflow matters.

Does a box that exactly equals the threshold get kept?+

Yes. The rule suppresses only when IoU is strictly greater than the threshold. Example 2 shows this: overlap is one third, the threshold is 40 percent, so both boxes stay. Using >= is the classic bug here.

Is O(n^2) fast enough for 5000 boxes?+

Yes. The worst case is about 12.5 million pair checks, each a handful of integer operations. No spatial index or clever pruning is needed. Sorting costs O(n log n) and the comparison loop dominates, which is fine.

How do I prepare for this in 48 hours?+

Write the solution once from scratch. Practice the intersection formula with clamping at zero, the custom sort comparator, and the cross-multiplied check. Test on both examples plus an empty input and touching edges. That covers nearly every way this question can go wrong.

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

OA at Wayve?
Invisible during screen share
Get it