Implement a stack with min() function
Anonym
Use regular stack implementation (push, pop, isEmpty, etc..) additional min() function will use a helper stack which will store all of the stack items when popping them out to find the minimum value. each time we'll compare the popped item to the minimum we've got so far and replace it accordingly. As soon as we hit "isEmpty" we will pop the items back from the helper stack and push them to the original stack. We will then return the minimum value found. Another approach relies within the pushing method. we can declare of a value in the class named "minimum" which will be modified every push and pop of the stack, it will be a bit difficult in the "pop" action but very easy in the "push" action.