Monotonic Stack Data Structure Explained

  Рет қаралды 48,361

AlgoMonster

AlgoMonster

Күн бұрын

Пікірлер: 75
@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. 9 ай бұрын
@@bluesteel1 😂
@adityapratapsinghtomer3624
@adityapratapsinghtomer3624 2 ай бұрын
@@JackHou-vw7hs my man
@sibiranganath
@sibiranganath 3 ай бұрын
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!
@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 🧠
@Brxndz_
@Brxndz_ Ай бұрын
This helped me solve Next Greater element without looking at your code, thanks!
@yoDQ
@yoDQ 10 ай бұрын
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.
@KuaisArts
@KuaisArts Жыл бұрын
Wow! Thanks for walking through the example, it was very insightful
@guinea_horn
@guinea_horn Ай бұрын
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.
@11csepratikshaargulewar71
@11csepratikshaargulewar71 Ай бұрын
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 Ай бұрын
Noted thanks!
@sandeepamarnath3295
@sandeepamarnath3295 Жыл бұрын
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 Жыл бұрын
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.
@LunaOoze
@LunaOoze 5 ай бұрын
Perfect explanation, thank you !
@algo.monster
@algo.monster 5 ай бұрын
Glad it was helpful!
@ignassablinskas9175
@ignassablinskas9175 7 ай бұрын
Very nice explanation, great job.
@algo.monster
@algo.monster 6 ай бұрын
Thank you!
@AyaGamal2010
@AyaGamal2010 2 ай бұрын
Great!
@hardiksinghal1360
@hardiksinghal1360 5 ай бұрын
Awesome explaination
@nagendrabommireddi8437
@nagendrabommireddi8437 9 ай бұрын
wow very good explanation. thank you..
@helloguys9201
@helloguys9201 Жыл бұрын
Wonderful Explanation and PPT's
@algo.monster
@algo.monster Жыл бұрын
Glad you liked it!
@sharwariphadnis1298
@sharwariphadnis1298 Жыл бұрын
Awesome video! Easy to understand
@alexsinx
@alexsinx Жыл бұрын
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 Жыл бұрын
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.
@dhruvsakariya3129
@dhruvsakariya3129 Жыл бұрын
you made it very easy by making visualizing approach. Thanks
@algo.monster
@algo.monster Жыл бұрын
Glad it was helpful!
@rahbanghani4097
@rahbanghani4097 10 ай бұрын
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.
@Spamuse-w3i
@Spamuse-w3i 10 ай бұрын
The background is too distracting
@himanshigarg1431
@himanshigarg1431 3 ай бұрын
Thank you so much
@algo.monster
@algo.monster 2 ай бұрын
You're most welcome
@googleit2490
@googleit2490 Жыл бұрын
New Topic Learned!! Sep'11, 2023 06:36 pm
@aleksandr_t
@aleksandr_t Жыл бұрын
Great video, thank you a lot!
@algo.monster
@algo.monster Жыл бұрын
Glad it helped!
@MahmoudHassan-m2t
@MahmoudHassan-m2t 2 ай бұрын
thanks
@Avighna
@Avighna 11 ай бұрын
Before learning this, I'd just use a segment tree for the first question xD.
@literallyjustsomegirl
@literallyjustsomegirl 10 ай бұрын
So helpful 😭🖤
@algo.monster
@algo.monster 10 ай бұрын
Glad it helped!
@parulgarg5362
@parulgarg5362 Жыл бұрын
Thanks for the video! Feedback on the moving background : VERY DISTURBING
@algo.monster
@algo.monster Жыл бұрын
Thanks and Noted!
@Tough802Peter
@Tough802Peter Жыл бұрын
bro is god
@AINikunjGour
@AINikunjGour Жыл бұрын
You are Osm bro..
@algo.monster
@algo.monster Жыл бұрын
Thanks ✌️
@codemonkey007
@codemonkey007 7 ай бұрын
Why the solution iterative the array from right side to left side, is this order matter?
@TragicGFuel
@TragicGFuel 4 ай бұрын
The order is a choice, you could have used a strictly increasing function instead
@gmoney_swag1274
@gmoney_swag1274 Ай бұрын
Couldn’t you also go from left to right? You could store the indexes in the stack and as soon as you add an element greater than the element at the top of the stack, you keep removing the top until it’s equal or greater to the new element, while updating their values (sorry for the bad explanation)
@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!
@tauicsicsics
@tauicsicsics 2 ай бұрын
great explanation but the moving background really makes me dizzy, could not watch it for more than 1 minute
@bluesteel1
@bluesteel1 Жыл бұрын
Nice
@kaszatus2
@kaszatus2 11 ай бұрын
Literally the worst sample, because not much of exploration... Maybe thats why for you its most confusing... As so its this video...
@RahulBansal14
@RahulBansal14 6 ай бұрын
The moving background make it hard to follow.
@samueladdisu3729
@samueladdisu3729 3 ай бұрын
The moving background is very distracting. I can't even watch the full video
@bogdan206
@bogdan206 11 ай бұрын
bro remove that background!
@ed2023bc
@ed2023bc 16 сағат бұрын
Slow down, it's not a race. Unless you don't understand what you are doing.
@tiger7858
@tiger7858 Жыл бұрын
very bad background
@szymonpiechutowski2340
@szymonpiechutowski2340 Жыл бұрын
yup!
@Trashcan-sz2qu
@Trashcan-sz2qu 7 ай бұрын
It's really helpful to stay focused actually
LeetCode is a JOKE with This ONE WEIRD TRICK
4:54
AlgoMonster
Рет қаралды 89 М.
Disrespect or Respect 💔❤️
00:27
Thiago Productions
Рет қаралды 43 МЛН
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 6 МЛН
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН
L5. Next Greater Element | Stack and Queue Playlist
18:25
take U forward
Рет қаралды 62 М.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 577 М.
Become a Malloc() Pro
6:58
thedoubleeguy
Рет қаралды 2,4 М.
I Solved 1583 Leetcode Questions  Here's What I Learned
20:37
ThePrimeTime
Рет қаралды 735 М.
Dynamic Programming isn't too hard. You just don't know what it is.
22:31
DecodingIntuition
Рет қаралды 197 М.
Monotonic Stack Explained
16:04
Kacy Codes
Рет қаралды 9 М.
Next Greater Element I - Leetcode 496 - Python
14:53
NeetCode
Рет қаралды 79 М.
How I would learn Leetcode if I could start over
18:03
NeetCodeIO
Рет қаралды 687 М.
8 patterns to solve 80% Leetcode problems
7:30
Sahil & Sarra
Рет қаралды 438 М.
Disrespect or Respect 💔❤️
00:27
Thiago Productions
Рет қаралды 43 МЛН