← Uber Interview Insights

Uber·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Uber SWE coding round with a question that's been circulating in other posts and apparently showed up in hack2hire too. Nothing shocking, but the follow-up added some complexity.

Questions Asked (2)

Q1

Implement a calculator that handles addition and subtraction.

Algorithms & Data Structures
Author's notes

Seen this one floating around in other posts so I wasn't totally blindsided.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem scope: input format, expected output, and constraints. Then outline a simple algorithm using a stack or two-pass approach to handle operator precedence, and discuss edge cases like negative numbers and whitespace. Finally, walk through a concrete example to validate the solution.

Pro tip: Mention that you would write unit tests for edge cases like '1+2-3' and ' 3 - 2 ' to ensure robustness, and discuss how to extend the solution to support multiplication and division if needed.

1. Clarify requirements

Ask about input format (string, tokens, etc.), output type, and constraints (e.g., integer overflow, whitespace handling). Confirm if only addition and subtraction are required.

2. Choose an approach

Decide between a stack-based evaluation or a two-pass method (first handle addition/subtraction, then combine). Explain why the chosen approach is efficient and easy to implement.

3. Handle edge cases

Identify and address edge cases such as negative numbers, multiple operators in a row, leading/trailing spaces, and empty input.

4. Implement and test

Write pseudocode or actual code, then walk through a few test cases to verify correctness. Discuss time and space complexity.

5. Discuss extensions

Mention how the solution could be extended to support multiplication, division, parentheses, or floating-point numbers, showing awareness of scalability.

Key Points to Mention

  • Operator precedence: addition and subtraction have the same precedence, so left-to-right evaluation is sufficient.
  • Using a stack to store intermediate results or operands for efficient evaluation.
  • Handling negative numbers and unary minus (e.g., '-5+3').
  • Time and space complexity: O(n) time and O(1) space if using a running sum with a sign variable.
  • Input parsing: tokenizing the string, skipping whitespace, and converting substrings to integers.
  • Testing: include cases like '1+2-3', ' 3 - 2 ', '0', and '-1-2'.

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

Q2

Given the calculator you just built, add input validation to verify the string is a valid expression before processing it.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The follow-up is where it gets a bit more interesting.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the requirements: what constitutes a valid expression (allowed operators, parentheses, numbers, whitespace, etc.) and what should happen on invalid input. Then, outline a validation strategy, such as tokenizing and using a state machine or recursive descent parser, and discuss trade-offs between strict and lenient validation. Finally, explain how you would integrate validation into the existing calculator without duplicating logic.

Pro tip: Mention that validation should be a separate, testable component that returns meaningful error messages, and that it can be reused for both client-side and server-side validation to ensure consistency and security.

1. Clarify requirements and edge cases

Ask the interviewer about the expected input format, allowed characters, and behavior on invalid input (e.g., throw exception, return error). Identify edge cases like empty string, unbalanced parentheses, consecutive operators, and division by zero.

2. Choose a validation approach

Decide between a simple regex, a state machine, or a full parser. Discuss trade-offs: regex is quick but limited for nested structures; a state machine is more robust; a parser can validate and evaluate simultaneously.

3. Design the validation logic

Outline the steps: tokenize the input, then iterate through tokens while maintaining state (e.g., expecting operand or operator). Handle parentheses by tracking depth. Return a boolean or throw an error with details.

4. Integrate with the calculator

Modify the calculator to call the validator before evaluation. Ensure that validation errors are propagated clearly. Avoid duplicating parsing logic by possibly reusing the tokenizer.

5. Test and discuss trade-offs

Propose test cases for valid and invalid expressions. Discuss performance implications (e.g., O(n) time) and whether validation should be strict or allow some flexibility (e.g., implicit multiplication).

Key Points to Mention

  • Tokenization and state machine for validation
  • Handling parentheses and operator precedence in validation
  • Error handling and meaningful error messages
  • Trade-offs between regex, state machine, and parser
  • Reusability of validation logic (e.g., for API input)
  • Time and space complexity of validation

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