Maximum Number of Robots Within Budget
A hard-tier problem at 37% community acceptance, tagged with Array, Binary Search, Queue. Reported in interviews at InMobi and 0 others.
Maximum Number of Robots Within Budget is a hard problem that shows up in real assessments, particularly at InMobi. The twist: you're managing a fleet of robots, each with a cost and a charge time, and you need to maximize how many you can operate within a budget constraint. The naive approach, checking every window, times out. You need to recognize that sliding window plus a data structure for tracking minimums (heap or monotonic queue) is the actual pattern. If this hits your live OA and you can't see the trick fast, StealthCoder surfaces the solution invisible to the proctor.
Companies that ask "Maximum Number of Robots Within Budget"
Maximum Number of Robots Within Budget 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. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.
Get StealthCoderThe problem looks like a greedy selection problem but the budget constraint couples the robots together in a way that breaks simple sorting. The key insight: use a sliding window to test feasible robot counts, and for each window, calculate the operational cost as the sum of charge times plus (window size minus 1) times the minimum charge time among them. A monotonic queue or priority queue tracks that minimum efficiently without recalculating it each time. Many candidates default to brute force window expansion and crash on the heap operations or miss that the minimum changes as the window slides. The budget acts as your stop condition, so binary search on window size is also viable. This is why it sits at 36.8% acceptance: the data structure choice and the cost formula aren't obvious from problem statement alone. StealthCoder's edge here is immediate pattern recognition during the timed assessment.
Pattern tags
You know the problem.
Make sure you actually pass it.
Maximum Number of Robots Within Budget recycles across companies for a reason. It's hard-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. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Maximum Number of Robots Within Budget interview FAQ
Is this really a hard problem or is it just marked hard?+
Accept rate of 36.8% confirms it. Most people either miss the monotonic queue optimization or miscalculate the charge formula. The sliding window itself is standard, but pairing it correctly with min-tracking and budget logic catches people off guard in a live setting.
Do I need to know all seven topics listed or just some?+
Not all. Binary search, sliding window, and either a monotonic queue or heap are core. Prefix sum helps some approaches. The full list reflects different valid solutions. Focus first on sliding window plus min-tracking before exploring others.
Why doesn't a simple greedy approach work?+
Greedy robot selection ignores the budget coupling: adding or removing one robot changes the total cost for all in the current set. The cost isn't additive per robot. Sliding window forces you to respect this dependency and find the longest consecutive valid subrange.
Is InMobi the only company asking this?+
Data shows InMobi in the reports. It's a lower-frequency problem overall, so you won't see it everywhere. But if you're prepping for InMobi specifically, this is a high-signal problem to nail.
How long should I spend on this in an OA before pulling the trigger?+
If you see the monotonic queue or heap pattern in the first 8-10 minutes, you're on track. If you're still sketching brute force at 15 minutes, you're probably chasing the wrong approach. That's when StealthCoder becomes your safety net.
Want the actual problem statement? View "Maximum Number of Robots Within Budget" on LeetCode →