Maximize the minimum asset value within an upgrade budget
I was asked this
No reports yet. Sign in to say where you were asked it.
A coding interview question asked in Uber's online assessment, last asked Jan 2026. It tests binary-search, greedy and arrays.
You hold a portfolio of n assets. Asset i is currently worth values[i]. You can upgrade any asset as many times as you like. Each upgrade of asset i costs costs[i] and adds values[i] to its worth, so after k upgrades asset i is worth values[i] * (1 + k).
You have a total upgrade budget budget. Spend at most budget so that the lowest final worth across all assets (the portfolio's floor) is as high as possible. Return that floor.
def max_floor_value(values: list[int], costs: list[int], budget: int) -> int: ...
Constraints
1 <= n <= 10^5-
1 <= values[i] <= 10^9,1 <= costs[i] <= 10^9 0 <= budget <= 10^14- Upgrades are whole steps. You do not have to spend the whole budget.
Example 1
values = [3, 5, 2], costs = [2, 1, 3], budget = 7
output: 4
Upgrade asset 0 once (cost 2, worth 6) and asset 2 once (cost 3, worth 4). The worths are [6, 5, 4]. A floor of 5 would need two upgrades on asset 2 (cost 6) plus one on asset 0 (cost 2), which is 8 and over budget.
Example 2
values = [1, 1, 1], costs = [1, 1, 1], budget = 5
output: 2
Upgrading each asset once (cost 3) gives a floor of 2. A floor of 3 needs two upgrades on every asset (cost 6).
Part 2. Also return how many times to upgrade each asset to reach the optimal floor.
Clarifying questions
- Is the floor always reachable as one of the final worths, or can it be any integer?
- Can upgrades be partial? (No, whole steps only.)
- What is the largest possible floor? It sets the search range and the integer size.
- For Part 2, if several upgrade plans give the best floor, is any of them fine?
What a strong answer covers
- Binary searches on the floor
F. ReachingFcosts the sum ofcosts[i] x (ceil(F / values[i]) - 1)over assets withvalues[i] < F. That cost never decreases asFgrows. - Sets the bounds:
min(values)always works, andmin(values) x (1 + budget // min(costs))is a safe upper limit. - Stops adding up a cost once it passes
budget, to avoid overflow in fixed-width languages. - That is O(n log(range)) time.
- Part 2 rebuilds the number of upgrades per asset from the best
F. - Tests both examples,
budget = 0, one asset, and assets that already sit above the floor.
Follow-ups
- Each asset can be upgraded at most
u[i]times. - An upgrade doubles the worth instead of adding
values[i]. - Maximize the total worth while keeping the floor at least
F. - Many budgets are asked at once.
Where it's asked
- Uber · Online assessment · Last asked Jan 202690 min · Two problems on a HackerRank-based platform, camera and screen share on · No AI
What it tests
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. New accounts get 5 credits: each one unlocks a question for good.
What the labs asked this week
A weekly email of what OpenAI, Anthropic and the other top AI labs asked engineers, round by round.
Sign in to submit your code; every attempt is kept here.
