FastPrepRound Prices to Match Target
Problems/Round Prices to Match Target

Round Prices to Match Target

Airbnb logoAirbnb● MediumINTERNFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives the task but no limits on the input. Here, there are 1 to 100 prices, each from 0 to 1000 with at most two digits after the decimal point, and the target is from 0 to 100000.

The report also does not say how equal fractions break ties or what to return when no rounding reaches the target. Here, the smaller index rounds up first, and an unreachable target returns an empty array.

Our version is about 90% the same as the reported question.

Given a float array prices and an integer target, round every price to either its floor or its ceiling so that the rounded values sum to target while minimizing the total absolute rounding error.

For example, prices = [1.2, 4.3, 5.8, 6.4] and target = 18 returns [1, 4, 6, 7].

Practice rule

  • If equal fractional parts compete for the last round-up position, prefer the smaller original index.
  • If no floor-or-ceiling assignment can sum to target, return an empty array.

Function

roundPricesToMatchTarget(prices: float[], target: int) → int[]

Examples

Example 1

prices = [1.2, 4.3, 5.8, 6.4]target = 18return = [1, 4, 6, 7]

Rounding every price down gives 1 + 4 + 5 + 6 = 16, so exactly two prices must be rounded up to reach 18.

A price rounded down has error equal to its fractional part, and a price rounded up has error equal to 1 minus its fractional part. Rounding up would cost 0.8 for 1.2, 0.7 for 4.3, 0.2 for 5.8 and 0.6 for 6.4, against 0.2, 0.3, 0.8 and 0.4 when rounded down.

Rounding up 5.8 and 6.4 gives [1, 4, 6, 7] with total error 0.2 + 0.3 + 0.2 + 0.6 = 1.3. Every other choice of two prices to round up gives a larger total error, so the answer is [1, 4, 6, 7].

Constraints

  • 1 <= prices.length <= 100
  • 0 <= prices[i] <= 1000
  • Each prices[i] has at most two digits after the decimal point.
  • 0 <= target <= 100000

Source note: Original source screenshot shows the Rounding in Price Breakdown statement, uniqueness guarantee, non-brute-force requirement, example, and error comparison.

More Airbnb interview questions

  • In-Memory File SystemOA · Seen Nov 2026
  • Shortest Uncommon SubstringONSITE INTERVIEW · Seen Nov 2026
  • Task Management SystemOA · Seen Nov 2026
  • Recipe Management SystemOA · Seen Nov 2026
  • Progressive Banking SystemOA · Seen Nov 2026
  • Read Across Sound TracksPHONE SCREEN · Seen Nov 2026
  • Text JustificationPHONE SCREEN · Seen Nov 2026
  • Credit Accounts with Scheduled TransfersOA · Seen Oct 2026
  • Decode and Store StringsPHONE SCREEN · Seen Oct 2026
  • Parcel Attribute Store with TTLOA · Seen Oct 2026

Similar questions at other companies

  • Maximize Revenue from Decreasing InventoryChubb · OAChubb interview questions
  • Return Exact Cash Register ChangeBank of America · OABank of America interview questions
  • Delete and Freeze GameRubrik · OARubrik interview questions
  • Maximum Three-Server Difficulty ScoreVisa · OAVisa interview questions
  • Max Transfer RateAmazon · OA
  • Apartment Housemate PreferencesGoogle · PHONE SCREENGoogle interview questions
  • Fair Electoral Vote ApportionmentBloomberg LP · PHONE SCREENBloomberg LP interview questions
  • Minimum Fuel Car AlignmentFivetran · PHONE SCREENFivetran interview questions
  • Hiking Club Fastest PaceInfosys · OAInfosys interview questions
  • Server Upgrade PlanningWells Fargo · OAWells Fargo interview questions

Interview reports that mention this question

  • Airbnb Intern OA and Phone Screens: 17 Experiences (Part 6 of 7)
  • Airbnb Intern OA and Onsite Rounds: 16 Experiences (Part 5 of 7)

Airbnb interview experiences

  • Airbnb OA · November 2026
  • Airbnb Campus and Full-Time SWE OA / Interviews: 9 Experiences
  • Airbnb Intern Phone Interviews: 21 Experiences (Part 7 of 7)
  • Airbnb Intern OA, Diplomacy Game: 19 Experiences (Part 4 of 7)
All Airbnb interview questionsSee Airbnb hiring insights
Saved
class Solution {
    public int[] roundPricesToMatchTarget(float[] prices, int target) {
      // write your code here
    }

}
Checking account…