← Google Interview Insights

Google·Software Engineer·Onsite - Multi Round·Intermediate

IntermediatePending
May 2026Mountain View

Summary

Google onsite at Mountain View, two coding rounds back to back. First one went really well, second was rougher but not a disaster. Still waiting to hear back and genuinely not sure which way it goes.

Questions Asked (2)

Q1

Find the shortest path in a graph using BFS, then solve two follow-up variations with additional constraints.

Algorithms & Data Structures
Author's notes

This went about as well as an interview can go.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clearly defining the graph representation and BFS algorithm for the base case, emphasizing time and space complexity. Then, for each follow-up, identify the additional constraint, discuss how it changes the problem, and propose modifications to BFS or alternative algorithms, analyzing trade-offs.

Pro tip: Always clarify the graph type (directed/undirected, weighted/unweighted) and constraints upfront; this shows thoroughness and prevents incorrect assumptions. For follow-ups, think aloud about edge cases and potential optimizations before coding.

1. Clarify the problem

Ask questions to understand the graph (directed/undirected, weighted/unweighted, cyclic/acyclic), source and target nodes, and any constraints. Confirm that BFS is suitable for unweighted shortest path.

2. Explain base BFS solution

Describe BFS with a queue, visited set, and distance tracking. Walk through an example, and state time complexity O(V+E) and space O(V).

3. Analyze first follow-up

Identify the additional constraint (e.g., weighted edges, obstacles, multiple sources). Discuss why BFS may not suffice and propose modifications (e.g., Dijkstra, multi-source BFS) or alternative algorithms.

4. Analyze second follow-up

Repeat for the second constraint, considering combinations or more complex scenarios (e.g., dynamic obstacles, path reconstruction). Discuss trade-offs and potential optimizations.

5. Summarize and test

Summarize the solutions, compare complexities, and mention testing with edge cases. Offer to code if needed.

Key Points to Mention

  • BFS guarantees shortest path in unweighted graphs; time complexity O(V+E).
  • Use a queue for BFS and a visited set to avoid cycles.
  • For weighted graphs, Dijkstra's algorithm is needed; BFS fails.
  • Multi-source BFS can handle multiple starting points by initializing queue with all sources.
  • Path reconstruction requires storing parent pointers during BFS.
  • Consider constraints like large graphs, memory limits, and dynamic updates.

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

Q2

Given a binary tree, find the maximum path sum (or a problem of similar structure and difficulty).

Algorithms & Data Structures
Author's notes

She showed up 25 minutes late and seemed like she had somewhere else to be.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem constraints (e.g., path definition, negative values) and then propose a recursive post-order traversal that computes the maximum gain from each subtree. At each node, update the global maximum path sum by considering the node's value plus the maximum gains from its left and right subtrees, and return the maximum gain that can be extended to the parent.

Pro tip: Emphasize that the path can start and end at any node, so you must consider the possibility of a path that goes through a node and connects its left and right subtrees. Also, mention that you handle negative values by taking the maximum of the gain and 0 to avoid including negative subtrees.

1. Clarify the problem

Ask questions to confirm the definition of a path (e.g., can it start and end at any node? Can it include negative values? Is an empty path allowed?) and the expected output (maximum sum).

2. Define the recursive function

Design a helper function that returns the maximum gain from a subtree rooted at a given node, where the gain is the maximum sum of a path starting at that node and going down to any node in its subtree.

3. Compute gains and update global maximum

For each node, recursively compute the left and right gains. Update the global maximum path sum as the maximum of the current global max and the sum of node's value plus left gain plus right gain.

4. Return the maximum gain to parent

Return the node's value plus the maximum of left gain and right gain (or 0 if both are negative) to represent the best path that can be extended upward.

5. Analyze complexity and test

State that the time complexity is O(n) and space complexity is O(h) due to recursion stack. Walk through a simple example to verify correctness.

Key Points to Mention

  • Path definition: a path is a sequence of nodes where each pair of adjacent nodes are connected; it can start and end at any node.
  • Handling negative values: use max(0, gain) to avoid including negative subtrees in the path.
  • Global variable to track the maximum path sum across all nodes.
  • Post-order traversal: process left and right subtrees before the current node.
  • Time and space complexity: O(n) time, O(h) space for recursion stack.
  • Edge cases: empty tree, single node, all negative values.

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