← Google Interview Insights

Google·Software Engineer·Onsite - Coding / Algorithms·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Round 2 at Google for a software engineer role. The coding question was a parser problem that escalated quickly into variadic argument support. Not a bad round but definitely not a comfortable one either.

Questions Asked (2)

Q1

Write a function that evaluates a nested expression string like 'add(2, mul(3, pow(4, 5)))' supporting addition, subtraction, multiplication, division, and exponentiation.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I went with a tokenizer feeding into a recursive descent parser which felt right and the interviewer seemed fine with the direction.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the grammar and constraints, then propose a recursive descent parser or stack-based evaluator. Walk through the algorithm step-by-step, handle operator precedence and parentheses, and discuss error handling and edge cases.

Pro tip: Mention that you would first write a tokenizer to separate function names, numbers, and punctuation, as this simplifies the parser and makes the code more maintainable. Also, discuss how to extend the solution to support variables or additional functions.

1. Clarify requirements and constraints

Ask about input format, allowed operators, error handling, and whether the expression is guaranteed to be valid. Confirm if the output should be a number or a string.

2. Design the parsing strategy

Choose between recursive descent, shunting-yard, or stack-based evaluation. Explain how to handle nested function calls and operator precedence.

3. Implement tokenization and parsing

Break the string into tokens (numbers, function names, parentheses, commas) and then parse recursively, evaluating as you go or building an AST.

4. Handle evaluation and edge cases

Evaluate the parsed expression, handle division by zero, negative exponents, and large numbers. Discuss error handling for malformed input.

5. Test and optimize

Walk through test cases including nested expressions and edge cases. Discuss time and space complexity and potential optimizations.

Key Points to Mention

  • Recursive descent parsing for nested function calls
  • Operator precedence and associativity (especially exponentiation being right-associative)
  • Tokenization to separate numbers, operators, and function names
  • Error handling for invalid syntax, division by zero, and unknown functions
  • Time and space complexity: O(n) time and O(d) space where d is nesting depth
  • Extensibility: how to add new operators or support variables

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

Q2

Extend your solution to support variadic arguments, e.g., 'add(1, 2, 3, mul(4, 5, 6))' where functions can take any number of arguments.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where I started sweating.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the existing solution's design and how it handles function calls and arguments. Then, explain how to generalize the argument parsing and evaluation to support variadic arguments, ensuring that the solution remains extensible and efficient. Finally, discuss potential trade-offs and edge cases.

Pro tip: Demonstrate awareness of real-world parsing challenges by mentioning how variadic arguments affect tokenization and evaluation order, and propose a clean abstraction like a function registry with arity handling.

1. Clarify the current solution

Briefly restate the existing approach for parsing and evaluating expressions, focusing on how functions and arguments are currently handled.

2. Identify necessary changes

Determine where the code assumes a fixed number of arguments and outline modifications to support any number of arguments, such as using a list or array.

3. Design the parsing strategy

Explain how to parse variadic arguments, e.g., by recursively parsing expressions until a closing parenthesis, and handling commas as separators.

4. Implement evaluation

Describe how to evaluate the function with a variable number of arguments, possibly using apply or spread syntax, and ensure functions like add and mul can accept any count.

5. Discuss trade-offs and edge cases

Mention considerations like performance, error handling for invalid arguments, and extensibility for future functions.

Key Points to Mention

  • Recursive descent parsing for nested expressions
  • Using a list/array to collect arguments dynamically
  • Function registry with arity flexibility
  • Handling commas and parentheses correctly
  • Evaluation order and short-circuiting (if applicable)
  • Error handling for malformed input

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