Unique Paths II - Leetcode 63 - Python

  Рет қаралды 18,765

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 16
@licokr
@licokr 8 ай бұрын
Great. You explain everything beginners might think and wonder. I can't complain anything about your videos. Thanks a lot neetcode
@superc91codm38
@superc91codm38 Жыл бұрын
There’s an O(1) solution using combinatorics in which we break it into two matrix and exclude all paths which strikes rock
@two697
@two697 Жыл бұрын
Could you elaborate on this? I'm not sure how this would be possible when there can be more than one obstacle
@Lucas-hr1mj
@Lucas-hr1mj Жыл бұрын
I like this problem. It is a very good and didactic example of dynamic programming.
@ronilitman7282
@ronilitman7282 3 ай бұрын
Thanks for yet another great video! Small note: If I am not mistaken your recursive solution doesn't work because you never collect the count when you are arriving to your base case, e.g something like this - if r == M - 1 and c == N - 1: return 1
@KshitijKale
@KshitijKale Жыл бұрын
We could also do it in O(1) space by using our obstacleGrid array as the dp array. We will use the same logic but we will store the total paths by it's negative value to differentiate between number of paths and the obstacle. In the end we will return absolute of the negative value at 0, 0.
@nikhil199029
@nikhil199029 Жыл бұрын
Generally changing input is illegal
@גלריש
@גלריש 5 ай бұрын
The explanation for this solution is amazing!
@hwang1607
@hwang1607 3 ай бұрын
here is a solution for unique paths 1 that I used this same logic to make: class Solution: def uniquePaths(self, m: int, n: int) -> int: row = [0] * n row[n-1] =1 for i in reversed(range(m)): for j in reversed(range(n-1)): row[j] = row[j] + row[j+1] return row[0]
@shashankgupta5687
@shashankgupta5687 10 ай бұрын
these dp problems takes days to understand and after watching editorials 5-6 times. Any suggestions pls??
@krateskim4169
@krateskim4169 Жыл бұрын
Elegant explanation
@rafaeldietrich8050
@rafaeldietrich8050 Жыл бұрын
Great explanation as always!!
@PrecisionWrittens
@PrecisionWrittens 8 ай бұрын
To help those a little confused by the final code, neet makes a slight space-optimization of only using a single array, which confused me a bit and I don't think would be reasonable for an interview. The unique-Paths-1 solution uses the much more straight-forward optimization of only using two-arrays (one to represent the prev row and the other to represent the current row) and I think you're better off just using that approach for this one. Recognizing that you don't actually need that 2nd array to populate the current rows dp values is not realistic for an interview imo. Clever AF though
@shavvasatya7131
@shavvasatya7131 Жыл бұрын
Great,as usual.
@nikhilsshastry6265
@nikhilsshastry6265 Жыл бұрын
This is a fake account, support the real neetcode
@NeetCodeIO
@NeetCodeIO Жыл бұрын
Actually this is my second channel - i post all the new LC videos here now :)
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 147 М.
Climbing Stairs - Dynamic Programming - Leetcode 70 - Python
18:08
Perfect Pitch Challenge? Easy! 🎤😎| Free Fire Official
00:13
Garena Free Fire Global
Рет қаралды 100 МЛН
Don't underestimate anyone
00:47
奇軒Tricking
Рет қаралды 15 МЛН
Twin Telepathy Challenge!
00:23
Stokes Twins
Рет қаралды 94 МЛН
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН
How I Approach a New Leetcode Problem (live problem solving)
25:31
Last Stone Weight II - Leetcode 1049 - Python
19:04
NeetCodeIO
Рет қаралды 16 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Path with Maximum Probability - Leetcode 1514 - Python
13:11
NeetCodeIO
Рет қаралды 14 М.
Rotating the Box - Leetcode 1861 - Python
15:14
NeetCodeIO
Рет қаралды 6 М.
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 197 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 577 М.
Unique Paths - Leetcode 62 - Dynamic Programming (Python)
13:03
Perfect Pitch Challenge? Easy! 🎤😎| Free Fire Official
00:13
Garena Free Fire Global
Рет қаралды 100 МЛН