Python data engineering interview problem. Difficulty: intermediate. Pattern: Stacks. About 14 minutes. Part of the Pro drill bank.
Implement a basic Stack with push, pop, top, and empty. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.
Implement class Stack with methods push(x), pop() (return value), top(), and empty() → bool.
Input: Stack push 1,2; pop; top Output: 2 then 1 LIFO order.
Topics: lakebench, python, stack, class.
More Python interview questions · All interview problems · Learn data engineering
Interview-style drill: Implement a basic Stack with push, pop, top, and empty.
Implement class `Stack` with methods `push(x)`, `pop()` (return value), `top()`, and `empty()` → bool. Keep the harness prints.