← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Uber software engineering interview with a parsing problem that looks deceptively simple but has a few gotchas depending on how you approach it. The problem was interesting enough that I kept thinking about cleaner solutions after the fact.

Questions Asked (1)

Q1

Given a string representing nested function calls of add(a, b) and sub(a, b), where arguments can be integers or further nested calls, evaluate the expression and return the result.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I went with a stack-based approach, tracking function names and argument lists as I walked the string character by character.

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 as it parses. Discuss handling nested calls, integer parsing, and operator precedence (though only add/sub are present).

Pro tip: Mention that you would write unit tests for edge cases like deeply nested calls, negative numbers, and whitespace variations to ensure robustness.

1. Clarify requirements and constraints

Ask about input format, allowed characters, maximum nesting depth, and whether arguments can be negative. Confirm the expected output type.

2. Define the grammar

Formalize the expression grammar: expr := 'add(' expr ',' expr ')' | 'sub(' expr ',' expr ')' | integer. This helps in designing the parser.

3. Design recursive evaluation

Write a recursive function that parses the string, identifies the function name, parses arguments recursively, and applies the operation. Use an index pointer to track position.

4. Handle edge cases and errors

Consider invalid input, unexpected tokens, and deep recursion (stack overflow). Discuss iterative alternatives or tail recursion if needed.

5. Analyze complexity and trade-offs

Time complexity is O(n) where n is string length; space O(d) for recursion depth. Compare with iterative stack-based parsing for memory efficiency.

Key Points to Mention

  • Recursive descent parsing with an index pointer
  • Grammar definition for nested function calls
  • Handling integers and negative numbers
  • Time and space complexity analysis
  • Edge cases: deep nesting, invalid syntax, whitespace
  • Trade-offs between recursive and iterative approaches

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