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 :)
김성현 알튜브 7월 3일 방송 FULL
5:40:20
[ALTUBE] 김성현TV
Рет қаралды 87 М.
小路飞还不知道他把路飞给擦没有了 #路飞#海贼王
00:32
路飞与唐舞桐
Рет қаралды 87 МЛН
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 21 МЛН
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 5 МЛН
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 147 М.
Climbing Stairs - Dynamic Programming - Leetcode 70 - Python
18:08
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Dijkstra's Algorithm - Computerphile
10:43
Computerphile
Рет қаралды 1,3 МЛН
Learning C - Build Your Own Lisp [1]
2:16:48
Domagoj Mišković
Рет қаралды 1,8 М.
Last Stone Weight II - Leetcode 1049 - Python
19:04
NeetCodeIO
Рет қаралды 16 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 577 М.
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 197 М.
Unique Paths - Dynamic Programming - Leetcode 62
10:48
NeetCode
Рет қаралды 138 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 183 М.
小路飞还不知道他把路飞给擦没有了 #路飞#海贼王
00:32
路飞与唐舞桐
Рет қаралды 87 МЛН