Leetcode 907 Sum of Subarray Minimums | Monotonic Stacks | Coding Decoded SDE Sheet

  Рет қаралды 10,491

Coding Decoded

Coding Decoded

Күн бұрын

Пікірлер: 28
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
Coding Decoded Monotic stack : docs.google.com/spreadsheets/d/1iyTY-BltHISj5bK2IFETPLhjbJdi-TrWeLXAyH0JQTI/edit#gid=0
@YashTyagi-c9k
@YashTyagi-c9k Ай бұрын
so awesome so amazing sunchit sir you are the best
@paragroy5359
@paragroy5359 11 ай бұрын
Great Content. Keep on making such videos.
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 11 ай бұрын
I will try my best
@jeffj97
@jeffj97 2 жыл бұрын
your organization is absolutely incredible. thank you so much!
@sagarbora7768
@sagarbora7768 2 жыл бұрын
Congrats Guruji on 14k organic growth
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja Жыл бұрын
Thanks Sagar
@aryangupta8952
@aryangupta8952 2 жыл бұрын
learnt a new concept of monotonic stack thanks man!
@manjeetyadav5830
@manjeetyadav5830 2 жыл бұрын
when we see number of minimum elements left or right from an index . Do we count the curr index as one among them
@chippapruthvi2773
@chippapruthvi2773 Жыл бұрын
+1
@hemu2723
@hemu2723 Жыл бұрын
you are really very amazing
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja Жыл бұрын
Wow, thank you
@tanson86
@tanson86 2 жыл бұрын
Hey Sunchit, When you get time can you reorganise the directory structure in git, introducing a directory for year can make navigation more easy. Not sure if it is an easy task but think about it... An example would be /2022/November/(*.java | *.cpp etc). Is the solution of this problem in GIT? I don't see it.
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
+1 to that, I wanted to do it long it back. but then realised that I have to update all the solution links of the videos released so far. Will make it more organised from 2023.
@pwnweb5734
@pwnweb5734 2 жыл бұрын
very well explained
@krateskim4169
@krateskim4169 2 жыл бұрын
awesome
@suryanshsinghchauhan5750
@suryanshsinghchauhan5750 2 жыл бұрын
Another approach using 1 stack and 1 dp array class Solution { public: int sumSubarrayMins(vector& arr) { stacks; int n=arr.size(); vectordp(n,0); int pre=-1; long long ans=0; int mod=1e9+7; for(int i=0;i=arr[i]){ s.pop(); } else break; } if(!s.size())pre=-1; else pre=s.top(); s.push(i); if(pre==-1){ dp[i]=((i+1)*arr[i])%mod; } else { dp[i]=(dp[pre]+((i-pre)*arr[i])%mod)%mod; } ans=(ans+dp[i])%mod; } return ans; } };
@manasideshmukh737
@manasideshmukh737 2 жыл бұрын
can you plz explain why you did this dp[i]=((i+1)*arr[i])%mod;
@suryanshsinghchauhan5750
@suryanshsinghchauhan5750 2 жыл бұрын
@@manasideshmukh737 if we are at an index whose element is the smallest till that index starting from left, then all the subarrays ending at that index will have the minimum element equal to that smallest element and to compute dp[i] which contains the sum of minimum of all the subarrays ending at 'i' I performed (i+1)*arr[I] where (i+1) represents the number of subarrays and arr[i] is the minimum element.
@suryanshsinghchauhan5750
@suryanshsinghchauhan5750 2 жыл бұрын
@@manasideshmukh737 hope this will help you.
@manasideshmukh737
@manasideshmukh737 2 жыл бұрын
@@suryanshsinghchauhan5750 understood...Thank you
@alphadrones23
@alphadrones23 2 жыл бұрын
why for rightMin the condition for pop is >= and for leftMin the condition is > ?
@RajatGupta-vu8xp
@RajatGupta-vu8xp 2 жыл бұрын
For equal condition, u can include that element either in left part or in right part, because it cant be in both .
@fnGamingz
@fnGamingz 2 жыл бұрын
1L 38k mails as unread 😀
@devendrabhuarya4917
@devendrabhuarya4917 Жыл бұрын
Your solution not pass all test cases
@DheerajKumarBarnwal
@DheerajKumarBarnwal 2 жыл бұрын
make your description space useful for others. Put relevant information in the first part like question link, solution link, reference video link or any document(which you are mentioning in the video). Just look at the description part yourself, its full of garbage. Its cluttered.
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
Thanks for such an honest feedback. Will work on it.
Sum of Subarray Minimums - Leetcode 907 - Python
18:51
NeetCodeIO
Рет қаралды 35 М.
L9. Sum of Subarray Minimum | Stack and Queue Playlist
23:35
take U forward
Рет қаралды 58 М.
Noodles Eating Challenge, So Magical! So Much Fun#Funnyfamily #Partygames #Funny
00:33
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 21 МЛН
This Game Is Wild...
00:19
MrBeast
Рет қаралды 152 МЛН
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 438 М.
Leetcode 931 Minimum Falling Path Sum  | Coding Decoded SDE Sheet
6:14
L10. Sum of subarray ranges | Stack and Queue Playlist
10:34
take U forward
Рет қаралды 27 М.
Best Books for Learning Data Structures and Algorithms
14:01
Engineering with Utsav
Рет қаралды 374 М.
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 197 М.
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 147 М.
Google Coding Interview With A Facebook Software Engineer
49:59
Clément Mihailescu
Рет қаралды 945 М.
Noodles Eating Challenge, So Magical! So Much Fun#Funnyfamily #Partygames #Funny
00:33