Design a stack which returns the minimum element in constant time O(1) and O(n) space

This post provides minimum element of the stack implementation in constant time O(1) and O(n) space. I have already discussed how to find minimum element of the stack using two stacks. This approach is an optimized version in which no auxiliary stack is used. Prerequisites : Knowledge of Java, stack data structure and understanding ofContinue reading “Design a stack which returns the minimum element in constant time O(1) and O(n) space”

Design a site like this with WordPress.com
Get started