Monotonic Stack Data Structure Explained

  Рет қаралды 44,406

AlgoMonster

AlgoMonster

Күн бұрын

Пікірлер: 71
@PrajaktaKarandikar-t3w
@PrajaktaKarandikar-t3w Жыл бұрын
Very well explained, would be easier to learn without the moving background.
@JackHou-vw7hs
@JackHou-vw7hs Жыл бұрын
I loved the moving background. It helped me stay focused
@bluesteel1
@bluesteel1 Жыл бұрын
Everything was fine before i read your comment. Now i cant ignore it .
@jigar2238
@jigar2238 Жыл бұрын
@@bluesteel1 😆
@siddhantprakash.
@siddhantprakash. 8 ай бұрын
@@bluesteel1 😂
@adityapratapsinghtomer3624
@adityapratapsinghtomer3624 Ай бұрын
@@JackHou-vw7hs my man
@sibiranganath
@sibiranganath 2 ай бұрын
It's a god level explanation of monotonic stack. A request from your rest subscriber: Don't have that running background in the tutorial it's irritating .
@PssGameplayER
@PssGameplayER Жыл бұрын
first time heard about Monotonic Stack, thanks for explaining it so properly
@algo.monster
@algo.monster Жыл бұрын
Our pleasure!
@yoDQ
@yoDQ 9 ай бұрын
Thank you for the monotonic stack explainer. It may be helpful to also show an image of the heights array above the image of the answer array to help visualize the relationship between the two better while popping and inserting.
@biswajeetpadhi100
@biswajeetpadhi100 Жыл бұрын
the background of this video is greatly designed. its very easy to focus with this background in motion
@algo.monster
@algo.monster Жыл бұрын
can't tell if it's positive or sarcasm haha but yeah glad you like it!
@biswajeetpadhi100
@biswajeetpadhi100 Жыл бұрын
@@algo.monster the background in motion acts as a boundary to the actual content, so I think it really works.
@szymonpiechutowski2340
@szymonpiechutowski2340 Жыл бұрын
I am a complete opposite to this idea, I feel like this 🤮 when I see it. It is not optimal for every 🧠
@guinea_horn
@guinea_horn 5 күн бұрын
Really good explanation. I'll agree with everyone else and say that the background is extremely distracting, and it actually makes the bitrate of the whole video go down, making the quality poor whether I select 144p or 1080p. I also feel like you didn't explain the algorithm before going through the problem with the heights of people. You started going through the example, but I didn't know precisely what it was you were doing or why you were making the decisions that you were making. I think it would be nice to have a plain explanation of the problem and how the algorithm solves it before going through the problem step by step.
@sandeepamarnath3295
@sandeepamarnath3295 11 ай бұрын
Great video thanks. Trying to understand how the monotonic stack approach would be of O(n) time. We traverse the array only once for sure, but what about the pop operations? For a few elements of array, we are popping out of stack multiple times until we find a stack element that is greater than the current element, so are we not counting this towards the time complexity? If length of stack is k, wouldn't the overall time be O(nk)? Thanks again!
@algo.monster
@algo.monster 11 ай бұрын
Every element in the array is processed exactly once. When an element is popped from the stack, it does not re-enter. Consequently, the maximum number of operations is 2n, accounting for each element being pushed and popped once.
@11csepratikshaargulewar71
@11csepratikshaargulewar71 5 күн бұрын
I kindly request that you should make videos avoiding moving backgrounds, as they can be distracting while concentrating . By the way, great explanation!
@algo.monster
@algo.monster 5 күн бұрын
Noted thanks!
@KuaisArts
@KuaisArts Жыл бұрын
Wow! Thanks for walking through the example, it was very insightful
@rahbanghani4097
@rahbanghani4097 8 ай бұрын
would you be kind enough to share what is the application that you are using for the walk through of the solution :) Thank you in advance.
@alexsinx
@alexsinx 11 ай бұрын
Why is the time complexity O(n) if we have two nested loops? shouldn't it be o(n*m) where n is the number of elements in the array and m is the number of elements in the stack?
@algo.monster
@algo.monster 11 ай бұрын
The code can be indeed deceiving. But remember each element enters or exits at most once. This is why monotonic stack is a efficient data structure.
@LunaOoze
@LunaOoze 4 ай бұрын
Perfect explanation, thank you !
@algo.monster
@algo.monster 4 ай бұрын
Glad it was helpful!
@ignassablinskas9175
@ignassablinskas9175 5 ай бұрын
Very nice explanation, great job.
@algo.monster
@algo.monster 5 ай бұрын
Thank you!
@sharwariphadnis1298
@sharwariphadnis1298 Жыл бұрын
Awesome video! Easy to understand
@AyaGamal2010
@AyaGamal2010 Ай бұрын
Great!
@nagendrabommireddi8437
@nagendrabommireddi8437 8 ай бұрын
wow very good explanation. thank you..
@hardiksinghal1360
@hardiksinghal1360 4 ай бұрын
Awesome explaination
@helloguys9201
@helloguys9201 Жыл бұрын
Wonderful Explanation and PPT's
@algo.monster
@algo.monster Жыл бұрын
Glad you liked it!
@Spamuse-w3i
@Spamuse-w3i 8 ай бұрын
The background is too distracting
@codemonkey007
@codemonkey007 6 ай бұрын
Why the solution iterative the array from right side to left side, is this order matter?
@TragicGFuel
@TragicGFuel 3 ай бұрын
The order is a choice, you could have used a strictly increasing function instead
@aleksandr_t
@aleksandr_t Жыл бұрын
Great video, thank you a lot!
@algo.monster
@algo.monster Жыл бұрын
Glad it helped!
@dimahodan232
@dimahodan232 Жыл бұрын
why brute force is O(n^2)? Each element doesn't start from the beginning of the array. Isn't it O(n*m) where m is i - k - 1? where k is the current element.
@algo.monster
@algo.monster Жыл бұрын
k is not an input parameter. we have to express it in n. after dropping the content it's n^2
@douglas5260
@douglas5260 Жыл бұрын
its n-1 + n-2 +n-3 ... = n**2
@BurtPredrag
@BurtPredrag Жыл бұрын
@@douglas5260 its not multiplication it should be addition
@douglas5260
@douglas5260 Жыл бұрын
@@BurtPredrag Yeah, I've corrected it. Thanks!
@himanshigarg1431
@himanshigarg1431 Ай бұрын
Thank you so much
@algo.monster
@algo.monster Ай бұрын
You're most welcome
@parulgarg5362
@parulgarg5362 11 ай бұрын
Thanks for the video! Feedback on the moving background : VERY DISTURBING
@algo.monster
@algo.monster 11 ай бұрын
Thanks and Noted!
@literallyjustsomegirl
@literallyjustsomegirl 9 ай бұрын
So helpful 😭🖤
@algo.monster
@algo.monster 9 ай бұрын
Glad it helped!
@tauicsicsics
@tauicsicsics Ай бұрын
great explanation but the moving background really makes me dizzy, could not watch it for more than 1 minute
@dhruvsakariya3129
@dhruvsakariya3129 Жыл бұрын
you made it very easy by making visualizing approach. Thanks
@algo.monster
@algo.monster Жыл бұрын
Glad it was helpful!
@kaszatus2
@kaszatus2 9 ай бұрын
Literally the worst sample, because not much of exploration... Maybe thats why for you its most confusing... As so its this video...
@MahmoudHassan-m2t
@MahmoudHassan-m2t 25 күн бұрын
thanks
@Avighna
@Avighna 9 ай бұрын
Before learning this, I'd just use a segment tree for the first question xD.
@AINikunjGour
@AINikunjGour Жыл бұрын
You are Osm bro..
@algo.monster
@algo.monster Жыл бұрын
Thanks ✌️
@googleit2490
@googleit2490 Жыл бұрын
New Topic Learned!! Sep'11, 2023 06:36 pm
@RahulBansal14
@RahulBansal14 5 ай бұрын
The moving background make it hard to follow.
@samueladdisu3729
@samueladdisu3729 Ай бұрын
The moving background is very distracting. I can't even watch the full video
@bluesteel1
@bluesteel1 Жыл бұрын
Nice
@Tough802Peter
@Tough802Peter Жыл бұрын
bro is god
@bogdan206
@bogdan206 10 ай бұрын
bro remove that background!
@tiger7858
@tiger7858 Жыл бұрын
very bad background
@szymonpiechutowski2340
@szymonpiechutowski2340 Жыл бұрын
yup!
@Trashcan-sz2qu
@Trashcan-sz2qu 6 ай бұрын
It's really helpful to stay focused actually
LeetCode is a JOKE with This ONE WEIRD TRICK
4:54
AlgoMonster
Рет қаралды 76 М.
I Solved 100 LeetCode Problems
13:11
Green Code
Рет қаралды 106 М.
Миллионер | 2 - серия
16:04
Million Show
Рет қаралды 1,3 МЛН
How it feels when u walk through first class
00:52
Adam W
Рет қаралды 20 МЛН
pumpkins #shorts
00:39
Mr DegrEE
Рет қаралды 108 МЛН
Кәсіпқой бокс | Жәнібек Әлімханұлы - Андрей Михайлович
48:57
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 453 М.
8 Data Structures Every Programmer Should Know
17:09
ForrestKnight
Рет қаралды 99 М.
Daily Temperatures - Monotonic Stack - Leetcode 739 - Python
11:52
The Math behind Hedging - Quant Trading 101 #some4 #quant
7:00
QuantIntuition
Рет қаралды 16 М.
L5. Next Greater Element | Stack and Queue Playlist
18:25
take U forward
Рет қаралды 47 М.
8 Design Patterns EVERY Developer Should Know
9:47
NeetCode
Рет қаралды 1 МЛН
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 601 М.
Sum of Subarray Minimums - Leetcode 907 - Python
18:51
NeetCodeIO
Рет қаралды 33 М.
Top 7 Algorithms for Coding Interviews Explained SIMPLY
21:22
Codebagel
Рет қаралды 413 М.
Миллионер | 2 - серия
16:04
Million Show
Рет қаралды 1,3 МЛН