Q. What is the time complexity of finding the minimum element in a stack that supports this operation?
A.
O(1)
B.
O(n)
C.
O(log n)
D.
O(n^2)
Solution
Finding the minimum element in a stack that supports this operation can be done in constant time, O(1), if a secondary stack is used to track minimums.