MEDIUMasked at 1 company

Minimize Rounding Error to Meet Target

A medium-tier problem at 45% community acceptance, tagged with Array, Math, String. Reported in interviews at Airbnb and 0 others.

Founder's read

You're given prices, a target sum, and a number of decimals. Round each price to meet the target exactly while minimizing total rounding error. Airbnb has asked this. It's a medium-difficulty problem that sits at the intersection of greedy and math, and most candidates either over-think the trick or miss the sorting step entirely. If this lands in your live OA and you blank on the approach, StealthCoder surfaces a working solution invisible to the proctor.

Companies asking
1
Difficulty
MEDIUM
Acceptance
45%

Companies that ask "Minimize Rounding Error to Meet Target"

If this hits your live OA

Minimize Rounding Error to Meet Target is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage.

Get StealthCoder
What this means

The trap is treating this like a pure rounding problem. You can't just round each price independently and hope they sum to the target. The real pattern is greedy with sorting. Calculate how much each price wants to round up or down, sort by the fractional parts, then greedily flip the cheapest rounding decisions until you hit the target sum. The error delta for each price is the difference between rounding up versus rounding down. StealthCoder handles the sorting and greedy selection instantly if you get stuck on the live assessment, letting you move past this problem in seconds instead of spiral.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Minimize Rounding Error to Meet Target recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer who got tired of watching his cohort grind for six months and still get filtered at the OA stage. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimize Rounding Error to Meet Target interview FAQ

Is this problem actually asked at Airbnb, and how often?+

Yes, Airbnb has reported this problem. It appears infrequently in most interview reports, so it's not a core drill, but that makes it more dangerous on a live OA. You either know the greedy-plus-sort pattern or you don't. Study it once; StealthCoder is your safety net if you blank.

What's the core trick I'm missing?+

You can't round each price independently. Sort by fractional error, then greedily decide which prices to round up based on their error contribution. The greedy choice always minimizes total rounding error. Most candidates miss the sorting step and burn time trying random rounding orders.

How does this relate to the Array and Greedy topics?+

You're given an array of prices and must use a greedy strategy to decide rounding direction. The greedy rule is simple once sorted, but the sorting itself is the crux. Array manipulation plus greedy selection covers both topics.

Is the Math part just understanding floating-point rounding, or something deeper?+

It's both. You need to handle decimal arithmetic correctly and calculate error deltas for each price. The math isn't complex, but off-by-one errors on the rounding direction or target sum are easy traps. Clean implementation is critical.

What if I'm stuck on this during my OA?+

StealthCoder reads the problem and delivers a working greedy solution in seconds, invisible to the proctor. No need to whiteboard or ask for hints. You get unstuck and move forward before time pressure builds.

Want the actual problem statement? View "Minimize Rounding Error to Meet Target" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.