GET MIN VALUE IN STACK

Hey!
I am unable to understand the exact logic of 2x-min and 2min -top ?
Could you plz elaborate or refer some other source where the code or its logic is given.
Thanks!

The logic lies in the part that you are not storing the number itself but a relation between the top of the element and the min element. So that relation is inverse of each other (top = 2x - min ; x = 2min - top) while pushing and popping. This is how we are getting a constant access time of min element

Bro please close this doubt as it is still classified as “open” even though it has already been resolved