Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Min Stack

Python data engineering interview problem. Difficulty: intermediate. Pattern: Stacks. About 14 minutes. Part of the Pro drill bank.

Stack that also retrieves the current minimum in O(1). Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.

Implement class MinStack with push(x), pop(), top(), and getMin().

Constraints

  • All operations O(1).

Examples

Input: push -2,0,-3; getMin; pop; top; getMin Output: -3, 0, -2 Min updates after pop.

Topics: lakebench, python, min, stack.

More Python interview questions · All interview problems · Learn data engineering

intermediate

Min Stack

Interview-style drill: Stack that also retrieves the current minimum in O(1).

Implement class `MinStack` with `push(x)`, `pop()`, `top()`, and `getMin()`. Keep the harness prints.