Number of Dice Rolls with Target Sum - Leetcode 1155 - Python

preview_player
Показать описание


0:00 - Read the problem
0:30 - Explaining Memoization solution
6:14 - Coding Memoization solution
10:01 - Explaining DP solution
15:17 - Coding DP solution

leetcode 1155

#neetcode #leetcode #python
Рекомендации по теме
Комментарии
Автор

A small improvement for the first solution (memoization) is to include a base case that stops recursion if the target becomes negative.

massimomonticelli
Автор

I'm done for today. New year resolution would be to learn dynamic programming 😅

YashRekha
Автор

Giving 5 easies in row just to hit u with DP problem on Christmas day 😂😂 Someone had a bad day

jayberry
Автор

Hello people. I have a hard time visualizing the backtracking tree and providing the Dynamic Programming optimization for it. Can anyone help me to get better at this and also to get better at solving DP problems....



🙂

harshithdesai
Автор

hey neetcode, i think we can rid off next_dp array if we build the solution up-bottom
mod=10**9+7
dp=[0]*target+[1]
for i in range(n-1, -1, -1):
for s in range(target+1):
dp[s]=0
for j in range(1, k+1):
if s+j>target:break
dp[s]=(dp[s]+dp[s+j])%mod
return dp[0]

m.kamalali
Автор

wonderful solution but if you go memoization ->tabulation ->tabulation(space optimized) it
would be helpful for beginners to learn all 3 variations

satwiktatikonda
Автор

The thumbnails of your previous videos were better with Company logos.. please continue putting company logos in the thumbnail as it is easy to pick company specific questions xD

lavanyam
Автор

I got the memoization solution myself but the bottom up tabulation solutions are tricky :/

onlinealias
Автор

Is that a medium complexity problem for real? You need to be a real smart ass to figure that out.
As for me, it's not about programming in general - it's more about having uni education to be able to build such math yourself.
I'm also curious how much time did it take for you to solve this problem?

kostiantynivanov
Автор

why don't you publish the solution on leetcode ?

ruzibayevich
Автор

Another problem down the drain for me. I barely understood your solution (not your fault). I need to study DP and backtracking. You would think a degree would prepare you for that.

ChrisBakare
Автор

I think I am too young for this concept 😅🤣

prakhar