← Google Interview Insights

Google·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

Two coding problems at Google for a software engineer role. The first was a recursive expression parser, the second was a graph/BFS chain reaction problem. Pretty standard algorithmic stuff but the nesting in problem one tripped me up more than I expected.

Questions Asked (2)

Q1

Implement a function that parses and evaluates a string of nested arithmetic calls like add(1, sub(1, 0)), supporting arbitrary nesting depth.

Algorithms & Data Structures
Author's notes

I went straight for recursion and it mostly worked, but splitting the arguments was where I fumbled.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the grammar and constraints, then implement a recursive descent parser that evaluates as it parses. Use a helper function that reads a function name, parses comma-separated arguments recursively, and applies the operation.

Pro tip: Mention that you can avoid building an AST by evaluating during parsing, which is more memory-efficient. Also, discuss handling edge cases like whitespace, negative numbers, and deeply nested inputs to show robustness.

1. Clarify requirements and edge cases

Ask about the allowed operations, input format (spaces, negative numbers), and error handling. Confirm whether to evaluate on the fly or build an AST.

2. Define the grammar

Write a simple grammar: expression = functionName '(' expression (',' expression)* ')' | number. This helps structure the parser.

3. Implement recursive descent parser

Write a parser that reads a function name, then parses arguments recursively until the closing parenthesis. Evaluate each function call as soon as its arguments are parsed.

4. Handle numbers and whitespace

Parse integer literals (including negative signs) and skip whitespace between tokens. Ensure the parser correctly identifies the end of an argument.

5. Test and discuss complexity

Test with nested examples and edge cases. Analyze time complexity O(n) and space complexity O(d) for recursion depth d.

Key Points to Mention

  • Recursive descent parsing technique
  • Grammar definition for nested function calls
  • Evaluation during parsing to avoid AST overhead
  • Handling of whitespace and negative numbers
  • Time and space complexity analysis
  • Error handling for invalid input (e.g., mismatched parentheses)

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

Q2

Given a list of bombs each with a position and blast radius, return the maximum number of bombs that can chain-explode if you choose exactly one bomb to detonate first.

Algorithms & Data Structures
Author's notes

Modeled it as a directed graph and ran BFS from each node, tracking visited counts.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the bombs as nodes in a directed graph where an edge exists from bomb A to bomb B if A's blast radius covers B's position. The problem then reduces to finding the node with the maximum reachable set in this directed graph, which can be solved using DFS/BFS from each node or more efficiently with strongly connected components and condensation. Return the size of the largest reachable set.

Pro tip: Clarify whether the graph is directed (chain reaction only propagates outward from the initial blast) and mention that the naive O(n^2) graph construction is acceptable for typical constraints, but you can optimize with spatial indexing if needed. Also, note that if the graph has cycles, you must handle them to avoid infinite loops.

1. Understand the problem and constraints

Confirm that bombs explode in a chain reaction: when a bomb explodes, it triggers all bombs within its blast radius, which then trigger others. Ask about input size to determine if O(n^2) is acceptable.

2. Build the directed graph

For each bomb i, check all other bombs j and add a directed edge i -> j if the distance between them is <= radius[i]. This takes O(n^2) time.

3. Find reachable set from each node

For each bomb, perform DFS or BFS to count how many bombs are reachable. Keep track of the maximum count. Use visited array to avoid revisiting nodes within a single traversal.

4. Optimize if needed

If n is large, consider using Tarjan's algorithm to find strongly connected components, condense the graph, and then compute reachable sets on the DAG using DP or topological order.

5. Return the maximum

After checking all starting bombs, return the maximum number of bombs that can be detonated in a chain reaction.

Key Points to Mention

  • Graph modeling: nodes as bombs, directed edges based on blast radius coverage.
  • Cycle handling: use visited set during traversal to avoid infinite loops.
  • Complexity analysis: O(n^2) for graph construction, O(n*(n+m)) for naive DFS, or O(n+m) per start; overall O(n^3) worst-case but can be optimized.
  • Optimization with SCC: condense cycles into super-nodes and compute reachable sizes via DP on DAG.
  • Edge cases: bombs with zero radius, bombs at same position, disconnected components.
  • Space-time tradeoff: using adjacency list vs. matrix, and potential spatial indexing for large n.

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