← Google Interview Insights

Google·Software Engineer·Onsite - Multi Round·Intermediate

IntermediatePending
Jun 2026Bangalore

Summary

Four rounds at Google for a software engineering role in Bangalore. Three coding rounds and a behavioral, with strong feedback across the board except for the third coding round where I missed an edge case and the interviewer ended things early. Recruiter said mixed-to-negative on that round but still moved me to team matching, so now I'm just waiting and overthinking it.

Questions Asked (3)

Q1

Implement a solution using topological sort.

Algorithms & Data Structures
Author's notes

Came up twice across different rounds which was a little surprising.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the problem to ensure it involves a directed acyclic graph (DAG) and requires a topological ordering. Then, choose between Kahn's algorithm (BFS-based) or DFS-based topological sort, explaining your choice based on factors like cycle detection or lexicographic order. Walk through the algorithm step-by-step, analyze time and space complexity, and discuss edge cases and potential optimizations.

Pro tip: At Google, interviewers value clear communication and the ability to handle ambiguity. Before diving into code, ask clarifying questions about input constraints, whether the graph is guaranteed to be a DAG, and if a specific ordering (e.g., lexicographically smallest) is required.

1. Clarify the problem

Ask questions to understand the graph representation, input size, and any constraints. Confirm that the graph is directed and acyclic, and determine if a specific order is needed.

2. Choose an algorithm

Decide between Kahn's algorithm (BFS-based) and DFS-based topological sort. Explain your choice based on factors like cycle detection, ease of implementation, or lexicographic ordering.

3. Walk through the algorithm

Describe the steps of your chosen algorithm in detail, using a small example to illustrate. Highlight how you handle cycles and ensure all nodes are processed.

4. Analyze complexity

State the time and space complexity of your solution. For both algorithms, it's O(V+E) time and O(V) space, but explain why.

5. Discuss edge cases and optimizations

Mention edge cases like empty graph, disconnected components, and cycles. Discuss potential optimizations, such as using a priority queue for lexicographic order.

Key Points to Mention

  • Definition of topological sort and its applications (e.g., task scheduling, dependency resolution).
  • Kahn's algorithm: compute in-degrees, use a queue, and decrement in-degrees of neighbors.
  • DFS-based approach: perform DFS and add nodes to the front of a list after visiting all descendants.
  • Cycle detection: if the topological sort doesn't include all nodes, a cycle exists.
  • Time and space complexity: O(V+E) time and O(V) space for both algorithms.
  • Handling disconnected graphs and ensuring all components are processed.

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

Q2

Solve a dynamic programming problem on trees.

Algorithms & Data Structures
Author's notes

Felt like the easier of the two problems in that round.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem and defining the DP state on the tree, typically involving subtrees and possibly whether a node is included or not. Then derive the recurrence relations, choose a traversal order (post-order DFS), and analyze time and space complexity. Finally, discuss optimizations or edge cases.

Pro tip: Always root the tree arbitrarily and use post-order DFS to compute DP values bottom-up; mention that you can often avoid recursion depth issues by using an iterative stack or increasing recursion limit.

1. Clarify the problem

Ask questions to understand the exact problem, constraints, and expected output. Confirm if the tree is rooted or unrooted, and if there are any special conditions.

2. Define DP state

Define what each DP state represents, such as dp[node][state] where state captures relevant information (e.g., whether the node is selected). Explain why this state is sufficient.

3. Derive recurrence

Write the recurrence relations that combine children's DP values to compute the parent's DP value. Consider all cases and transitions.

4. Choose traversal and implement

Use post-order DFS to compute DP values bottom-up. Discuss iterative vs recursive implementation and handle large trees.

5. Analyze complexity and optimize

State time and space complexity, typically O(n) time and O(n) space. Mention any possible optimizations or trade-offs.

Key Points to Mention

  • Rooting the tree and using post-order traversal
  • Defining DP states that capture necessary information (e.g., include/exclude node)
  • Combining children's results efficiently
  • Handling base cases (leaf nodes)
  • Time and space complexity analysis
  • Edge cases: single node, skewed tree, large input

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

Q3

Solve an interval-based problem.

Algorithms & Data Structures
Author's notes

This is the one that hurt.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the exact interval problem (e.g., merge, insert, intersect) and constraints, then propose a solution using sorting or sweep-line techniques. Walk through the algorithm with a concrete example, analyze time/space complexity, and discuss edge cases and potential optimizations.

Pro tip: Always confirm whether intervals are inclusive/exclusive and if they are pre-sorted; this shows attention to detail and can drastically simplify the solution. Also, mention how you would handle large inputs or streaming data to demonstrate scalability thinking.

1. Clarify the problem

Ask questions to understand the exact interval operation, input format, constraints, and edge cases (e.g., overlapping, touching, empty intervals).

2. Choose an approach

Decide between sorting-based, sweep-line, or interval tree approaches based on problem requirements and constraints.

3. Walk through an example

Trace the algorithm on a small example to verify correctness and identify potential pitfalls.

4. Analyze complexity

State the time and space complexity of your solution and compare with alternatives if relevant.

5. Discuss edge cases and optimizations

Mention how you handle edge cases and propose optimizations or alternative approaches for large-scale inputs.

Key Points to Mention

  • Sorting intervals by start time to simplify merging or insertion
  • Sweep-line technique for finding intersections or maximum overlaps
  • Handling edge cases: empty input, single interval, intervals that just touch
  • Time complexity: O(n log n) due to sorting, O(n) for linear scans
  • Space complexity: O(n) for output or O(1) extra if in-place
  • Potential use of interval trees for dynamic interval queries

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