DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
easy
Stack

Min Stack

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Min Stack** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Auxiliary min-stack or store (val, currentMin) pairs **Edge Cases to Consider:** - (1) Single element - (2) Push in decreasing order - (3) Pop min element

Examples

Example 1
Input: push(-2); push(0); push(-3); getMin(); pop(); top(); getMin()
Output: -3; 0; -2
Explanation: Classic
Example 2
Input: push(1); getMin()
Output: 1
Example 3
Input: push(2); push(1); getMin(); pop(); getMin()
Output: 1; 2
Explanation: Pop restores min

Constraints

  • ▪Input arguments are within valid ranges
  • ▪Optimize for execution speed
  • ▪Handle null/empty inputs gracefully

Watch Out For Edge Cases

  • ▪Single element
  • ▪Push in decreasing order
  • ▪Pop min element
Frequently Asked At
AmazonMicrosoftGoogleMetaAdobeTCS