← Meta Interview Insights

Meta·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Meta SWE coding round, grid path problem with obstacles. Pretty standard dynamic programming territory but the obstacle handling trips people up if they're not careful.

Questions Asked (1)

Q1

Given a 2D grid where some cells are blocked by obstacles, count the number of unique paths from the top-left to the bottom-right corner, moving only right or down.

Algorithms & Data Structures
Author's notes

Classic DP setup.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem constraints (grid dimensions, obstacle representation, and whether the start/end can be blocked). Then explain a dynamic programming approach where dp[i][j] represents the number of paths to cell (i,j), computed from the top and left neighbors, with obstacles setting dp to 0. Finally, discuss time and space complexity and possible optimizations.

Pro tip: Mention that you can optimize space to O(n) by using a 1D DP array and updating it in place, and note that if the start or end is blocked, the answer is immediately 0.

1. Clarify constraints and edge cases

Ask about grid size, obstacle representation, and whether the start or end can be blocked. Confirm that movement is only right and down.

2. Define the DP state and recurrence

Let dp[i][j] be the number of unique paths to cell (i,j). If the cell is blocked, dp[i][j] = 0; otherwise dp[i][j] = dp[i-1][j] + dp[i][j-1], with base case dp[0][0] = 1 if not blocked.

3. Implement the DP solution

Iterate through the grid row by row, filling the DP table. Handle the first row and first column separately or initialize them appropriately.

4. Analyze complexity and optimize space

State that time complexity is O(m*n) and space can be reduced from O(m*n) to O(n) by using a 1D array and updating it in place.

5. Test with examples and edge cases

Walk through a small example, including cases with obstacles, blocked start/end, and a 1x1 grid.

Key Points to Mention

  • Dynamic programming state definition and recurrence relation
  • Handling obstacles by setting dp to 0
  • Base case initialization (dp[0][0] = 1 if not blocked)
  • Time complexity O(m*n) and space complexity O(m*n) or O(n) with optimization
  • Edge cases: blocked start/end, empty grid, 1x1 grid
  • Comparison with alternative approaches like combinatorics (if no obstacles) or BFS/DFS (inefficient due to overlapping subproblems)

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