DataDriven
LearnPracticeInterviewDiscussDailyJobs

The Min Tracker

A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
medium
Seniority
L4

Problem

Implement a class MinStack supporting push(x), pop(), and get_min(). All three operations must run in O(1) time. get_min returns the current minimum element in the stack without removing it. The test harness drives your class through a top-level function run_operations(operations, arguments). It is given two parallel lists: operations is a list of operation names and arguments is a list of argument lists. The first operation is always "MinStack" (with an empty argument list), which constructs a fresh stack. For each subsequent operation it calls the matching method on the instance with the unpacked arguments. run_operations returns a parallel list of results, one per operation: None for the constructor, None for push, None for pop, and the current minimum (an int) for get_min.

Summary

The stack remembers the best it ever saw.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.

Related

  • All Practice Problems
  • Mock Interview Mode
  • Python Interview Questions
  • Data Engineering Interview Prep Guide
  • Daily Challenge
  • Data Engineering Lessons