Why we inserting the smaller element than the original element we get, if current_element<vcurrent_minimum.
Stack Minimum in constant time
Are you saying why we insert 2*x - cur_min if x<cur_min?
Then this article explains it https://www.geeksforgeeks.org/design-a-stack-that-supports-getmin-in-o1-time-and-o1-extra-space/ as to why this trick works
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.