Stack get min video

what you want to tell in this video we can directly find minimum by comparing the values while inserting .
what is the need of inserting and poping

you can not find minimum directly like this.
lets figure it out by an example.
push 5
push 3
push 10
get min ------> min is 3
push 2
push 8
get min -------> min is 2
pop // 8 will be popped out
pop //2 will be popped out
get min ------> now min value is 3 (not 2) . min = min of all elements present in stack

so your approach will fail when we start popping.

thanks

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.