MEDIUMasked at 27 companies

Basic Calculator II

A medium-tier problem at 46% community acceptance, tagged with Math, String, Stack. Reported in interviews at Highspot and 26 others.

Founder's read

Basic Calculator II shows up in live assessments at Tesla, Meta, Airbnb, and 24 other companies. It's a medium-difficulty problem with a 46% acceptance rate, which means nearly half the candidates who attempt it fail. The trap is thinking you can parse and evaluate left-to-right. You can't. Multiplication and division have to be handled before addition and subtraction, and if you don't get the operator precedence logic right on the first try during a live OA, you'll burn 20 minutes on edge cases. This is exactly where StealthCoder pays for itself: if the precedence trick isn't fresh, the tool solves it invisibly and you move on.

Companies asking
27
Difficulty
MEDIUM
Acceptance
46%

Companies that ask "Basic Calculator II"

If this hits your live OA

Basic Calculator II 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 StealthCoder
What this means

The core insight is that you can't evaluate the expression as you parse it. You need to respect operator precedence, which means deferring addition until you've collected all multiplication and division results. A stack approach works: push the result of the current number and operator onto the stack, then sum the stack at the end. The gotcha is handling spaces, multi-digit numbers, and the last number correctly. Many candidates get the stack logic right but miss the final flush of the pending operation. Others build a full expression tree or try to use regex, which adds unnecessary complexity. On string and math problems like this, the stack pattern is standard at scale, but the implementation details are easy to botch under pressure. If you blank on the approach during the assessment, StealthCoder reads the problem and surfaces a working solution in seconds, no proctor visibility.

Pattern tags

The honest play

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

Basic Calculator II 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.

Basic Calculator II interview FAQ

Is this still asked at Meta, Tesla, and Airbnb?+

Yes. All three appear in the top companies list for this problem. It's a classic interview problem because it tests understanding of operator precedence, stack usage, and string parsing simultaneously. You're unlikely to dodge it if you interview there.

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

Operator precedence. You must evaluate '*' and '/' before '+' and '-'. Most candidates try to evaluate left-to-right and fail on mixed operators. A stack stores intermediate results and respects precedence. The second trick: flush the last number and operation at the end.

How does this relate to the other Math and Stack topics?+

It combines all three. Math (operator precedence rules), String (parsing characters and building numbers), and Stack (storing and deferring results). It's a full-skill problem, not a single-topic drill. That's why the acceptance rate is low.

Can I use a different approach, like regex or recursion?+

Technically yes, but no. The stack approach is the canonical solution at these companies. Regex adds fragility and cognitive load. Recursion is overkill. The interviewer expects to see the stack pattern. Stick to it.

How much time should I spend on this in a live OA?+

If you know the stack pattern, 12-15 minutes to code and test. If you're unsure about the approach, you're at risk. This is where having StealthCoder as a safety net matters: a wrong approach eats 30 minutes and sinks your score.

Want the actual problem statement? View "Basic Calculator II" 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.