Clarify the problem constraints (grid size, number of blocked cells) and confirm that paths are counted modulo a large prime if needed. Then present a dynamic programming solution where dp[i][j] represents the number of paths to cell (i,j), computed as the sum of paths from the top and left neighbors, with blocked cells having 0 paths. Finally, discuss time and space complexity and possible optimizations like using a 1D array.
Pro tip: Mention that if the grid is very large but blocked cells are sparse, you can use combinatorics with inclusion-exclusion or coordinate compression to avoid O(R*C) time. Also, always ask about modulo to prevent integer overflow.
Ask about grid dimensions, number of blocked cells, whether start or end can be blocked, and if the answer should be modulo a prime. Confirm movement is only right and down.
Let dp[i][j] be the number of paths from start to (i,j). Initialize dp[start] = 1. For each cell, if blocked, dp[i][j] = 0; else dp[i][j] = dp[i-1][j] + dp[i][j-1].
Iterate row by row, using a 1D array to store the previous row's values. Update dp[j] = dp[j] + dp[j-1] for each row, skipping blocked cells.
Time complexity is O(R*C), space O(C). Discuss alternative approaches like combinatorics for sparse obstacles, and when they might be preferable.
Walk through a small grid with obstacles, verify the count, and check cases where start or end is blocked, or no path exists.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.