← Otter.ai Interview Insights

Otter.ai·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Interviewed for a software engineer role at OtterAI and got LeetCode 227, the basic calculator problem with +, -, *, / operators and no parentheses. Pretty standard coding screen, nothing too wild.

Questions Asked (1)

Q1

Implement a basic calculator that evaluates a string expression containing non-negative integers and the operators +, -, *, and /, with integer division truncating toward zero. No parentheses involved.

Algorithms & Data Structures
Author's notes

The multiplication and division before addition and subtraction part tripped me up at first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a stack to handle operator precedence by evaluating multiplication and division immediately, while deferring addition and subtraction. Iterate through the string, building numbers and applying operators based on precedence, then sum the stack at the end.

Pro tip: Clarify edge cases upfront, such as division by zero and integer overflow, and discuss how you would handle them. Also, mention that you can solve it without a stack by using a running total and a last operand, which shows deeper understanding.

1. Clarify requirements and edge cases

Confirm that the expression is valid, contains only non-negative integers and +, -, *, /, and that division truncates toward zero. Ask about handling division by zero and potential integer overflow.

2. Choose data structures and algorithm

Decide to use a stack to store intermediate results, or alternatively use variables to track the last operand and result. Explain that this handles operator precedence without parentheses.

3. Iterate through the expression

Parse numbers and operators sequentially. When encountering * or /, apply the operation immediately to the last value on the stack (or last operand). For + or -, push the number (or its negation) onto the stack.

4. Compute final result

After processing all characters, sum all values in the stack (or combine the running total with the last operand) to get the final result.

5. Test with examples and edge cases

Walk through examples like '3+2*2', '3/2', '1-1+1', and discuss how the algorithm handles them. Mention potential pitfalls like negative intermediate results and division truncation.

Key Points to Mention

  • Operator precedence: multiplication and division before addition and subtraction.
  • Use of a stack to defer addition/subtraction and immediately evaluate multiplication/division.
  • Integer division truncates toward zero (e.g., 3/2 = 1, -3/2 = -1).
  • Handling multi-digit numbers by accumulating digits.
  • Time and space complexity: O(n) time, O(n) space for stack (or O(1) space with optimized approach).
  • Edge cases: division by zero, large numbers causing overflow, and expressions starting with a negative number (if allowed).

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.