A easy Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- easy
- Seniority
- L3
Problem
Implement a stack via an operations list. Each operation is a list: ['push', x], ['pop'], ['peek'], ['is_empty']. Return a parallel list of return values: None for push, the popped value (or None if empty) for pop, the top value (or None if empty) for peek, True/False for is_empty.
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 grades it automatically.