← Google Interview Insights

Google·Technical Product Manager·Technical Phone Screen·Senior

Senior
Jul 2026

Summary

Google TPM interview with a classic maze problem. Not much context around the experience itself but the question was a solid algorithmic one that caught me thinking about edge cases more than I expected.

Questions Asked (1)

Q1

Given a maze, find the total number of unique paths from the source to the destination.

Algorithms & Data Structures
Author's notes

I went straight to dynamic programming but kept second-guessing whether the problem allowed revisiting cells.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (e.g., maze size, obstacles, movement directions) and then explain a dynamic programming approach where dp[i][j] represents the number of unique paths to cell (i,j). Discuss how to handle obstacles and optimize space, and mention alternative approaches like BFS/DFS with memoization.

Pro tip: As a PM, emphasize the importance of understanding the problem's real-world constraints and trade-offs (e.g., time vs. space complexity) before diving into the algorithm. Show that you can translate technical solutions into product decisions.

1. Clarify the problem

Ask questions to understand the maze representation, allowed moves (e.g., right/down only or all four directions), obstacles, and constraints. Confirm whether paths are unique by cell sequence or by direction sequence.

2. Choose an approach

Decide between dynamic programming (for grid with only right/down moves) or graph traversal (BFS/DFS with memoization) for more complex mazes. Explain why the chosen approach is suitable.

3. Define the recurrence

For DP, define dp[i][j] as the number of paths to cell (i,j). Derive the recurrence: dp[i][j] = dp[i-1][j] + dp[i][j-1] if no obstacle, else 0. Initialize base cases.

4. Analyze complexity

State time and space complexity (e.g., O(m*n) time and space for DP). Discuss potential optimizations like using a 1D array to reduce space to O(n).

5. Discuss edge cases and extensions

Mention edge cases (e.g., no path, start/end blocked) and how to handle them. If time permits, discuss extensions like weighted paths or multiple destinations.

Key Points to Mention

  • Dynamic programming recurrence and base cases
  • Handling obstacles by setting dp to 0
  • Space optimization using a 1D array
  • Time and space complexity analysis
  • Alternative approaches (BFS/DFS with memoization) for mazes with arbitrary moves
  • Edge cases: start or end blocked, no path exists

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