insyte
ExploreCommunityGitHubDev
Settings

insyte

Turn any tech concept into a live, interactive simulation you can play with.

© 2026 insyte. Open source.

Product

ExploreCommunitySettings

Open Source

GitHubReport an issueLicense

Explanation

Design a stack that returns the minimum element in O(1) — without sorting. Uses a clever auxiliary stack to track minimums at every level.

Step through to reveal explanations.

-- / --
MinStack initialized — both stacks empty
getMin()
0
Main Stack
top of stack
— empty —
call stack
Min Stack (tracks min per level)
top of stack
— empty —
call stack
-- / --
MinStack initialized — both stacks empty
getMin()
0
Main Stack
top of stack
— empty —
call stack
Min Stack (tracks min per level)
top of stack
— empty —
call stack

Explanation

Step through to reveal explanations.