Sum of Total Strength of Wizards | Leetcode 2281 | Monotonic Stacks Prefix Sum | Contest 294 🔥🔥

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

Coding Decoded

Coding Decoded

Күн бұрын

Пікірлер: 50
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
🔥Complete Contest 294 Nailed: kzbin.info/aero/PLEI-q7w3s9gRfzqXpc7w7_3cy5tI9Abm7
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
Try these questions: 🔥 Daily Temperatures kzbin.info/www/bejne/mH7VlHWarLebaLc, 🔥 Next Greater Element I kzbin.info/www/bejne/jGbVaIOHnch9ebM 🔥 Largest Rectangle in Histogram kzbin.info/www/bejne/qHzaq6N3ecmjobs 🔥 Complete playlist: kzbin.info/aero/PLEI-q7w3s9gQpqrVq_9VkYugtILlqSB1I
@nitinkumar5974
@nitinkumar5974 2 жыл бұрын
unique thing about your lectures is that your lectures are very short and very easy to understand Thanks
@rounakjoshi6680
@rounakjoshi6680 2 жыл бұрын
Bro U deserve 1e9 likes for explaining this question.⚡⚡⚡⚡⚡⚡
@saranghae3720
@saranghae3720 Жыл бұрын
Easy, Short, Clean & Concise Explanation
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja Жыл бұрын
Glad you liked it
@nikhilprakash729
@nikhilprakash729 2 ай бұрын
Great Explanation Sir..
@shrimpo6416
@shrimpo6416 Жыл бұрын
Quality video as always, thank you! (not very hard after learning all questions in your mono stack sheet by heart, thank you for sharing!)
@topG448
@topG448 7 ай бұрын
The brute force of this problem is 0(N^2)
@noedie4973
@noedie4973 2 жыл бұрын
thanks a lot, got the intuition initally but was intimidated by the pre-prefix thing and couldn't solve, nicely explained here!
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
Glad it helped!
@ashisranjandey7541
@ashisranjandey7541 7 ай бұрын
Short and crisp and sound. Great explanation, Man .. Kudos.
@paragroy5359
@paragroy5359 11 ай бұрын
Nice video. Great Content, keep on making such videos.
@pavniujla654
@pavniujla654 2 жыл бұрын
Best explanation on youtube, the way you explain nobody else call
@aryanjain7645
@aryanjain7645 2 жыл бұрын
nice explanation!
@tanmaychanda398
@tanmaychanda398 Жыл бұрын
I'm not able to understand the multiplication part , can someone make me understand that?
@amarbudhiraja3210
@amarbudhiraja3210 2 жыл бұрын
nice explaination!
@m.ohammadalikhan
@m.ohammadalikhan Жыл бұрын
Why have you taken the size of preSum and prePrefix array as n+1 and n+2? Why not just n?
@hymnish_you
@hymnish_you 2 жыл бұрын
Thank you ❤
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
You're welcome 😊, glad seeing your message after long
@hymnish_you
@hymnish_you 2 жыл бұрын
@@CodeWithSunchitDudeja Feeling good that you know your subscribers well. Such a humble person you are :)
@nakshatrasharma9022
@nakshatrasharma9022 2 жыл бұрын
Great explanation, variable(stacks) naming could be a little better, but good job overall. Cheers!
@Bloggerrusrb
@Bloggerrusrb 2 жыл бұрын
thank you!
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
You're welcome!
@aleksandrg2717
@aleksandrg2717 2 жыл бұрын
thank you
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
You're welcome
@sanketnaik387
@sanketnaik387 2 жыл бұрын
Is it for those who have learnt DSA?
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
True.. if you don't know DSa don't solve it it will break your confidence
@sanketnaik387
@sanketnaik387 2 жыл бұрын
@@CodeWithSunchitDudeja Yeah bhaiya. I am a college fresher currently and DSA is in my 3rd semester but I have just started learning it. Although the code was tough to grasp which you wrote but the way you broke the problem was very nice. It was just like our Math teacher making us understand permutations and combination.
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
@@sanketnaik387 thanks that u liked it...
@manishsakariya4595
@manishsakariya4595 2 жыл бұрын
Sum(L+1,i) = Prefix[i+1] - prefix[L+1] is right? try with 1,2,3,4,5,6 sum(2,5) = prefix[6]-prefix[2] = 21-3 = 19 [According to above formula?] which is wrong. 2+3+4+5=14
@reenaupadhyay9218
@reenaupadhyay9218 2 жыл бұрын
I also have this doubt.. shouldn't it be Sum(L+1,i) = prefix[I] - prefix[L+1 - 1]??
@himadrinath1502
@himadrinath1502 5 ай бұрын
yes it is wrong sum(L+1,i)=prefix(i+1)-prefix(L)
@arnabmishra9638
@arnabmishra9638 2 жыл бұрын
Great explanation
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
Glad it was helpful!
@inimace
@inimace 2 жыл бұрын
In test case [1,3,1,2] Won't the sub array 1,3,1 counted twice when minimum element is 1 (at index 0) and 1 (at index 2) ?
@ritabrotoganguly5729
@ritabrotoganguly5729 2 жыл бұрын
that's why you have to use >= for left and > for right or vice versa
@cwmayank
@cwmayank 2 жыл бұрын
Hi, I think code shared by you failed for 81/82 (may be because of mod). I always hate taking mod because sometimes it give errors that I can't debug. Anyway, thank you so much for making video on this question. You're videos are always short and to the point. Please keep making such videos. 1 Request - Could you please make videos on past contests of leetcode on daily basis. No need to give the code even the intuition will do. A lot of beginners like me suffer while practicing previous leetcode challenges because there are not good videos on them. Thanks again............
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
Here is the complete playlist: kzbin.info/aero/PLEI-q7w3s9gRwAEYzYkvVTsYHDi2-ffdL
@ashwinigautam1003
@ashwinigautam1003 2 жыл бұрын
link for monotonic stack ??
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
Try these questions: 🔥 Daily Temperatures kzbin.info/www/bejne/mH7VlHWarLebaLc, 🔥 Next Greater Element I kzbin.info/www/bejne/jGbVaIOHnch9ebM 🔥 Largest Rectangle in Histogram kzbin.info/www/bejne/qHzaq6N3ecmjobs 🔥 Complete playlist: kzbin.info/aero/PLEI-q7w3s9gQpqrVq_9VkYugtILlqSB1I
@Siddharth1924
@Siddharth1924 2 жыл бұрын
fails the last test case on lc
@suhasnayak4704
@suhasnayak4704 2 жыл бұрын
Just add +MOD at the end in this line ans += ((prePrefix[right[i]+1] - prePrefix[i+1]) * (i-left[i]) % MOD + MOD - (prePrefix[i+1] - prePrefix[left[i]+1]) * (right[i] - i) % MOD)*strength[i] + MOD;
@deepanprakash4362
@deepanprakash4362 2 жыл бұрын
kzbin.info/www/bejne/gWSUh4B7apt_adE sum(L+1, i) should be Prefix(i)- prefix(L) , how it is Prefix(i+1)-Prefix(L+1) , for ex: 1, 8,7,3 (L, L+1, i, i+1) here sum(8,7) should be Prefix(7)-Prefix(1) = 16-1 but in your example Prefix(i+1)-Prefix(L+1) => 19-9 = 10 which is wrong, can you please explain?
@anupamasingh1239
@anupamasingh1239 2 жыл бұрын
All test case didn't pass
@suhasnayak4704
@suhasnayak4704 2 жыл бұрын
Just add +MOD at the end in this line ans += ((prePrefix[right[i]+1] - prePrefix[i+1]) * (i-left[i]) % MOD + MOD - (prePrefix[i+1] - prePrefix[left[i]+1]) * (right[i] - i) % MOD)*strength[i] + MOD;
@mrprime557
@mrprime557 2 жыл бұрын
Took way too much time to understand :') makes me feel dumb af
@LegitGamer2345
@LegitGamer2345 2 жыл бұрын
Nice explanation !
@CodeWithSunchitDudeja
@CodeWithSunchitDudeja 2 жыл бұрын
Great seeing your message after long.. hope you are doing fine
Weekly Contest 294  |   6077. Sum of Total Strength of Wizards
29:30
codingMohan
Рет қаралды 4,1 М.
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 20 МЛН
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 8 МЛН
УДИВИЛ ВСЕХ СВОИМ УХОДОМ!😳 #shorts
00:49
Monotonic Stack Data Structure Explained
5:43
AlgoMonster
Рет қаралды 48 М.
Coding Interview Problem: Largest Rectangle in a Histogram
16:18
Jackson Gabbard
Рет қаралды 309 М.
Unboxing the Raspberry Pi CM5 Development Kit
11:36
Level 2 Jeff
Рет қаралды 18 М.
7 Common Excel Mistakes You HAVE to Fix Today!
11:39
MyOnlineTrainingHub
Рет қаралды 22 М.
How To Pass Technical Interviews When You Suck At LeetCode
14:32
Maximum Performance of a Team - Leetcode 1383 - Python
14:53
NeetCode
Рет қаралды 31 М.