Broken Calculator
A medium-tier problem at 55% community acceptance, tagged with Math, Greedy. Reported in interviews at Millennium and 1 others.
You're at Millennium or Nutanix and the problem is Broken Calculator. You've got a number, a target, and a broken calculator that can only multiply by 2 or subtract 1. Most candidates see it as a graph search problem and build BFS or Dijkstra. That works, but it's slow and it burns time. The greedy insight cuts through the noise. If you freeze up on the trick during the live assessment, StealthCoder runs invisibly and surfaces the optimal approach in seconds. 55% acceptance rate means half the candidates miss something fundamental.
Companies that ask "Broken Calculator"
Broken Calculator 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 greedy pattern here is work backwards. Start at the target and reverse the operations: instead of multiply by 2 or subtract 1, you divide by 2 (if even) or add 1 (if odd). Moving backward forces the optimal moves to become obvious because division always shrinks the number faster than subtraction expands it. Most candidates build a forward BFS or attempt a recursive memo solution, which gets exponential blowup on large inputs. The backwards greedy walk is O(log n) because division by 2 halves the search space each time. On a live OA, if you're stuck in the forward approach or your solution times out, StealthCoder gives you the reversal pattern and a clean implementation instantly.
Pattern tags
You know the problem.
Make sure you actually pass it.
Broken Calculator 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. 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.
Broken Calculator interview FAQ
Is Broken Calculator still asked at FAANG?+
Not as common as dynamic programming classics, but it shows up in middle-tier interviews, especially math-heavy companies. Millennium and Nutanix have both asked it. It's a signal problem for greedy reasoning and thinking backwards.
What's the trap most candidates fall into?+
Forward BFS on large numbers explodes because you explore too many states. The greedy backwards approach skips almost all of them. If your code TLEs during practice, reverse your logic. Division by 2 is your pruning strategy.
How does this relate to Math and Greedy?+
Math covers the modulo and division checks (is n even/odd). Greedy is the insight that working backward with division always dominates working forward with subtraction. Combining both topics is the solve.
Do I need DP or BFS for this?+
No. Greedy backwards walk is simpler and faster. You loop: if target is even, divide by 2; if odd, add 1. Stop when target equals start. No memoization, no queue, no visited set needed.
How much time should I spend on Broken Calculator in prep?+
15 to 20 minutes to nail the backwards logic. If you're in Greedy, it's a good warm-up. In the live OA, if you blank on the pattern, that's where StealthCoder becomes your safety net.
Want the actual problem statement? View "Broken Calculator" on LeetCode →