Unique paths in a grid with obstacles dynamic programming | leetcode#63

Опубликовано: 04 Октябрь 2024
на канале: Joey'sTech
1,733
24

In this video of JoeyTech's dynamic programming tutorial, you are going to learn a DP problem that is frequently asked in the interviews - Unique path in a grid with obstacles.
The problem is on the leetcode with the serial no 63 as Unique paths II.

Once you watch this video till the end, you are going to add one fantastic problem to your bucket of dynamic programming problems.
This will strengthen your interview preparation, especially those interviews which focus on coding and algorithms.

The problem statement of the Unique paths in a grid with obstacles DP problem gives you a matrix of m x n dimensions.

In this video, we are going to work on the below matrix

0 0 0
0 1 0
0 0 0

You need to find the number of unique paths in this matrix where an obstacle is present. The obstacle is represented by 1 here.
You will be starting from the top-left cell (0,0) and travel to the bottom right corner (m,n).
You can only move right or down in this matrix.

You need to keep in mind that when an obstacle is encountered you can't move to that cell. So, you can't move from (0,1) to (1,1)
or from (1,0) to (1,1).

I have already created a video on finding the total number of unique paths in a matrix (leetcode#62).
You must refer to its tutorial(Unique paths) to understand this Dynamic programming problem better.

   • Find all possible paths between two p...  

---------------------------------- Also Watch --------------------------------
Solve Matrix chain multiplication using dynamic programming
   • Learn to solve matrix chain multiplic...  

Minimum cost path in a matrix dynamic programming
   • How to find minimum cost path in a ma...  

Maximum sub square matrix problem using dynamic programming
   • Dynamic Programming Tutorial : Maximu...