Why is scanning for getMin not ideal?
Practice this question from Min Stack - Auxiliary stack Pattern Practice Quiz, with options and an explanation.
Question
Why is scanning for getMin not ideal?
Option A — Correct answer
It makes getMin O(n)
Option B
It uses too little space
Option C
It cannot push negative numbers
Option D
It changes stack order
Explanation
Scanning the stack makes getMin O(n), not O(1).