Problems Involving Grids - 3
Learn to solve hard to difficult grid-based problems with dynamic programming.
We'll cover the following
Problem statement
The problem in this lesson tries to solve the following type of question:
Finding the number of ways to reach a particular position in a grid from a starting position (given that some cells are blocked).
The problem statement is as follows:
The input is three integers, M, N, and P, each denoting the number of rows, number of columns, and number of blocked cells respectively. In the next P lines, each line has exactly 2 integers, i and j, denoting that the cell (i, j) is blocked. Find the number of ways to reach (M, N).
Solution: Dynamic programming approach
The implementation below explains how to proceed with the solution. The problem is the same as the previous one, except for few a extra checks resulting from the cells being blocked.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.