Question DSA-STK-0076
HardWhat does 'min stack' need to answer getMin() in O(1)?
- A.
Scanning the stack
- B.
A second stack (or pairs) recording the minimum at each level
- C.
Sign up free to see the answer and a step-by-step explanation.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Stacks question
What does 'min stack' need to answer getMin() in O(1)?
Scanning the stack
A second stack (or pairs) recording the minimum at each level
Sign up free to see the answer and a step-by-step explanation.
A heap
Sorting after each push