Leetcode : Minimum cost to merge stones (Dynamic Programming)

  Рет қаралды 19,629

Shivank Goel

Shivank Goel

Күн бұрын

Пікірлер: 37
@raviprakash4-yearb.tech.ch375
@raviprakash4-yearb.tech.ch375 2 жыл бұрын
Thanks a lot 2 bar dekhne k bad aur leetcode discuss pdhne k bad aakhir smjh m aahi gya
@apurvpandey17
@apurvpandey17 Жыл бұрын
Thank you bhai kya explanation diya ab jaa k samajh mai aaya
@nedames3328
@nedames3328 2 жыл бұрын
Excellent step-by-step explanation. Other speakers don't say why we need the l mod (k-1) logic. I think you could make your presentation even better by explaining that l is the largest index -- not the length. The examples could run from a0, a1, ..., al. That would make it clear that when (l = length - 1) piles compress down to (k-1) piles we need to add the full sum from 0 to l to account for merging the remaining pile with the final k piles. Thanks.
@sheikhmkrifat7749
@sheikhmkrifat7749 Ай бұрын
to merge k elements we need at least k elements, thats means length should be at least k, then condition should be like L < K , but you you said l < k - 1 thats confusing, and at several point you didnt clarify some equation and some logic, k + k - 1 this i got it, but how its related to came up in (n - 1) % (k - 1) == 0 this equation, in an interview we have to clarify this kind of thing properly.
@mukulvarshney669
@mukulvarshney669 11 күн бұрын
he is talking length in terms of index lets say length is 1 then he is saying length is 0. I mean L
@sayantaniguha8519
@sayantaniguha8519 3 жыл бұрын
Can this also be solved as a variation of matrix chain multiplication ?
@Munnu-hs6rk
@Munnu-hs6rk 10 ай бұрын
yes
@divyamthacker2498
@divyamthacker2498 5 ай бұрын
@@Munnu-hs6rk how, can you provide the code
@veganengineer2019
@veganengineer2019 4 жыл бұрын
typo at 5:38..... it should be (n-k)%(k-1)
@raghavmittal5352
@raghavmittal5352 4 жыл бұрын
(n-1)%(k-1) can also work
@sudeshnaC
@sudeshnaC 4 жыл бұрын
n=k+(k-1)+(k-1)+....(k-1) [say for x times] n=k+x*(k-1) n=k+x*(k-1) +1 -1 [Adding +1 and -1] n=1+(x+1)*(k-1) n-1=(x+1)*(k-1) (n-1)%(k-1)= {(x+1)*(k-1)}%(k-1) (n-1)%(k-1)=0
@AbhinayKacham
@AbhinayKacham Жыл бұрын
Nice explanation.
@bishakhdutta8427
@bishakhdutta8427 2 жыл бұрын
if this was on codeforces what would be the rating? like this is not a typical hard on leetcode. definitely one of the hardest I have solved.
@watchlistsclips3196
@watchlistsclips3196 2 жыл бұрын
When k=3 and if we are at len4 ex:i=0, j=3 we can't merge the stones rt as if we merge 3 stones we are left with 2 there is no way we can merge them but you are writing dp[i][j] exists i am not getting this
@kushagrasrivastava8641
@kushagrasrivastava8641 4 жыл бұрын
thanks, explanation could be better but it gave a very nice idea to understand this question so works for me!!
@kushagrasrivastava8641
@kushagrasrivastava8641 4 жыл бұрын
also, could you tell why we are iterating mid as for(mid=x;mid
@learnandgrow4220
@learnandgrow4220 Жыл бұрын
@@kushagrasrivastava8641 to ensure that u can reduce the no. of piles or can get minimum no of piles
@pawandeepchor89
@pawandeepchor89 3 жыл бұрын
Awesome video 👏👏
@learnandgrow4220
@learnandgrow4220 Жыл бұрын
Amazing vro , Actually I was not getting why mid+=K , why not mid++ , but cleared thanks a lot
@raseshgupta6276
@raseshgupta6276 3 жыл бұрын
Nicest explanation for this problem
@tushargoyaliit
@tushargoyaliit 5 жыл бұрын
What do u mean by length 0, why r u considering length zero means 1 pile. length k-1 means k piles. What's this?.these are not number of line segements.
@questlove7377
@questlove7377 4 жыл бұрын
@@tushargoyaliit No dude. Length 0 will have to be considered for the sake of dp. Where it means that for l=0, cost is 0 too.
@RiteshYadav-vm9tb
@RiteshYadav-vm9tb 3 жыл бұрын
Superb Explanation!!!
@utkarshgupta6258
@utkarshgupta6258 2 жыл бұрын
why Greedy is failing??
@meme_engineering4521
@meme_engineering4521 2 жыл бұрын
it's a scam, it always fails
@vaibhavkumargautam
@vaibhavkumargautam 11 ай бұрын
​@@meme_engineering4521😂😂😂
@RajeevKumar-xz2zr
@RajeevKumar-xz2zr 4 жыл бұрын
great explanation nice video!!! but I would recommend to make the smaller video, you seem to repeating few point, expain and move. anyway nice video well done!
@raghuvanshraj1831
@raghuvanshraj1831 4 жыл бұрын
Is it possible for you to link your code?
@shivankgoel
@shivankgoel 4 жыл бұрын
github.com/shivankgoel/compcoding/blob/master/leetcode/q1000.cpp
@saurabhkumarkaushal469
@saurabhkumarkaushal469 3 жыл бұрын
Great explanation
@joydeeprony89
@joydeeprony89 2 жыл бұрын
poor video sound
@vedant9173
@vedant9173 3 жыл бұрын
Brilliant explanation
@hjain1011
@hjain1011 3 жыл бұрын
Inaudible
@utkarshgupta2909
@utkarshgupta2909 7 ай бұрын
Everyone is writing same types of comment Excellent explanation. Stop collecting people to write same type of comment. Poor Audio quality. At 13:07 I didnt understood if (l % (k-1) ==0 ) then sum all of them . What was that ?
@IMSOURAVM
@IMSOURAVM 4 жыл бұрын
Thank you for the great explanation.
@shivankgoel
@shivankgoel 4 жыл бұрын
Glad you liked it!
@bangmasterx4658
@bangmasterx4658 2 жыл бұрын
very poor explanation
Leetcode : Longest Palindromic Subsequence (Dynamic Programming)
14:41
БУ, ИСПУГАЛСЯ?? #shorts
00:22
Паша Осадчий
Рет қаралды 3 МЛН
Hoodie gets wicked makeover! 😲
00:47
Justin Flom
Рет қаралды 138 МЛН
DP 50. Minimum Cost to Cut the Stick
30:02
take U forward
Рет қаралды 145 М.
How to Do 90% of What Plugins Do (With Just Vim)
1:14:03
thoughtbot
Рет қаралды 907 М.
Minimum Cost to Cut a Stick - Leetcode 1547 - Python
12:15
NeetCodeIO
Рет қаралды 14 М.
CppCon 2014: Mike Acton "Data-Oriented Design and C++"
1:27:46
Stone Game - Leetcode 877 - Python
22:00
NeetCode
Рет қаралды 31 М.
Coding Interviews Are Easy (Leetcode, BinarySearch.com)
2:12:45
Errichto Hard Algorithms
Рет қаралды 9 М.
LeetCode (Hard) - 1000. Minimum Cost to Merge Stones
36:30
H William Polenz
Рет қаралды 7 М.
C Programming Tutorial for Beginners
3:46:13
freeCodeCamp.org
Рет қаралды 14 МЛН