← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Jun 2026

Summary

Senior SWE phone screen at Uber, centered almost entirely on expression parsing. Two distinct variants came up: a functional nested add/sub evaluator and an infix calculator. The problems sound approachable until you're mid-implementation and realize your comma-splitting logic is completely wrong.

Questions Asked (2)

Q1

Given a string expression using add(a, b) and sub(a, b) that can be nested arbitrarily, write a function to evaluate it and return the integer result.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The problem gets presented verbally with like two or three examples and zero formal grammar, so you're kind of guessing at the edge cases.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the grammar and constraints, then propose a recursive descent parser that evaluates the expression on the fly. Discuss handling nested calls, negative numbers, and whitespace, and analyze time and space complexity.

Pro tip: Mention that you can evaluate during parsing without building an AST, but be ready to discuss when an AST is preferable for extensibility or debugging.

1. Clarify requirements and constraints

Ask about input format, allowed operations, nesting depth, integer range, and error handling. Confirm whether the expression is always valid and if whitespace is present.

2. Design a parsing strategy

Choose a recursive descent parser that reads the function name, then parses arguments separated by commas. Use a helper to parse integers and handle nested expressions recursively.

3. Implement evaluation logic

Write a function that returns the result of the current expression. For add, return left + right; for sub, return left - right. Ensure recursion handles arbitrary nesting.

4. Handle edge cases

Consider negative numbers, whitespace, and deeply nested expressions. Discuss potential stack overflow for very deep nesting and mitigation strategies.

5. Analyze complexity and trade-offs

State that time complexity is O(n) where n is the length of the string, and space complexity is O(d) for recursion depth d. Compare with iterative stack-based parsing.

Key Points to Mention

  • Recursive descent parsing for nested expressions
  • On-the-fly evaluation vs. building an AST
  • Handling negative numbers and whitespace
  • Time and space complexity analysis
  • Stack overflow risk for deep nesting and iterative alternatives
  • Extensibility for adding new operations

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

Q2

Evaluate an infix arithmetic expression string that contains digits, +, -, parentheses, and spaces. You cannot use any built-in expression evaluator.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Classic stack problem but the unary minus tripped me up for a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints (e.g., integer division, unary operators) and then propose a two-stack or recursive descent solution. Walk through the algorithm step-by-step, emphasizing how parentheses and operator precedence are handled, and analyze time/space complexity.

Pro tip: Mention that you would first confirm whether the expression is guaranteed valid and whether division is integer or floating-point, as these details affect the implementation. Also, discuss how you would test edge cases like nested parentheses and negative numbers.

1. Clarify Requirements and Edge Cases

Ask about input validity, operator set, integer vs. floating-point division, and unary operators. Confirm expected behavior for edge cases like empty strings or spaces.

2. Choose an Algorithm

Select between a two-stack approach (operators and operands) or recursive descent parsing. Explain why one might be preferred based on constraints.

3. Outline the Algorithm

Describe how to handle digits, operators, and parentheses. For two-stack: push operators based on precedence, evaluate when encountering ')' or lower precedence. For recursive descent: define grammar and parse accordingly.

4. Analyze Complexity and Trade-offs

State time and space complexity (O(n) time, O(n) space for both approaches). Discuss trade-offs: two-stack is iterative and simpler for basic expressions; recursive descent is more extensible for complex grammars.

5. Test with Examples

Walk through a sample expression like '3 + (2 * 4) - 5' to demonstrate correctness. Mention testing edge cases such as nested parentheses and multiple-digit numbers.

Key Points to Mention

  • Operator precedence and associativity rules
  • Handling parentheses using a stack or recursion
  • Time and space complexity analysis (O(n) time, O(n) space)
  • Edge cases: invalid expressions, unary minus, spaces, multi-digit numbers
  • Trade-offs between two-stack and recursive descent approaches
  • Testing strategy and validation of the solution

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