← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jul 2026Remote

Summary

Meta coding screen, basically a calculator problem but stripped down to just addition and multiplication. Felt manageable once I saw the constraint about no parentheses.

Questions Asked (1)

Q1

Given a string expression with non-negative integers and only '+' and '*' operators (no parentheses), evaluate and return the result.

Algorithms & Data Structures
Author's notes

My first instinct was to reach for a full operator stack like you'd use for the general calculator problem.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that the expression has no parentheses and only '+' and '*' operators, so operator precedence applies. Use a single-pass stack-based approach: maintain a stack of terms, applying multiplication immediately and pushing addition terms. Finally, sum the stack to get the result.

Pro tip: Mention that you can also solve it in O(1) space by keeping a running total and a last multiplied term, which shows you think about optimization beyond the obvious stack solution.

1. Clarify and Confirm

Ask clarifying questions: Are there spaces? Can numbers be multi-digit? Are there negative numbers? Confirm that only '+' and '*' are present and no parentheses.

2. Choose Data Structure

Decide between a stack-based approach (simpler, O(n) space) or a running total with last term (O(1) space). Explain the trade-offs.

3. Parse and Evaluate

Iterate through the string, building multi-digit numbers. When an operator is encountered, apply the previous operator: for '*', multiply the last term; for '+', push the term or add to total.

4. Handle Final Term

After the loop, apply the last operator to the final number and add to the result.

5. Test and Optimize

Walk through edge cases (single number, leading zeros, large numbers) and discuss time/space complexity. Mention potential optimizations.

Key Points to Mention

  • Operator precedence: multiplication before addition.
  • Stack-based evaluation: push numbers, apply '*' immediately, sum at end.
  • O(1) space optimization: maintain running total and last multiplied term.
  • Handling multi-digit numbers and parsing without using built-in eval.
  • Time complexity O(n) and space complexity O(n) or O(1).
  • Edge cases: single number, no operators, large integers, leading zeros.

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