Programming Interview Question: design a stack with min(stack) operation in constant time

preview_player
Показать описание
Interview Question:-
design a stack with min(stack) operation in O(1) time.

This video explains the solution to the problem of implementing min() operation for stack data structure.

Source code:-

Рекомендации по теме
Комментарии
Автор

Dear Friends,

If you like our content and would like us to continue making great content for you, please spread the word about IDeserve.
A share/appreciation from you on social network would mean the world to us!


Thanks,
-Team IDeserve.

IDeserve
Автор

i came from another video expaling the same thing but when compared to him youre God of explaination . come on vruh you gota do leet code explaintion. pls do that many of us are eagerly waiting

damudaran
Автор

Explained very nicely. Keep it up!. Subscribed!

vishalmahavratayajula
Автор

holy crap you're a genius THANK YOU

maggie
Автор

There is a method that has time O(1) and space O(1) as well. This approach uses O(n) space.

harikumaralangode
Автор

pop method should have a return type I suppose. Checking which element is popped is a good practice.

mrmca
Автор

Can you please post a video on use of a single array to implement three stacks..

Achilleus
Автор

Very good explanation. Could you add more videos on Hashing techniques. Also please add couple of videos on how to approach/solve system design questions. I guess there are no very good tutorials on System Design

adityadeshpande
Автор

Wonderful explaination. Your last solution is O(1) time and O(1) space ?. Is that correct ?. coz you are not using additional stack to store the min values.

shwetadk
Автор

1. temp.next = top;
2. top = temp;
I'm confused. After execution of line 2, what is the value in top.next? What is the value in temp.next?

daanishraj
Автор

so the runtime for the push and pop are O(1) or O(n)?

sharma