The Tail End
A easy Python interview practice problem on DataDriven. Write and execute real python code with instant feedback.
- Domain
- Python
- Difficulty
- easy
- Seniority
- L3
Problem
We're replaying a stream of stack commands against a last-in, first-out stack: push a value, pop the top, peek at it, check whether the stack is empty, or ask for the smallest value currently on it, each encoded as a list with the command name first like `['push', 5]` or `['min']`. Run the commands in order and return one result per command, and make the smallest-value lookup stay fast no matter how many pushes and pops came before it.
Summary
Push, pop, peek. The basics that break people.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and checks it automatically.