⌘K
Flycodx

Stack with Minimum Query

Stack with Minimum Query

EasyStacks0% accepted

Given a sequence of PUSH and MIN operations, process each. PUSH X adds X to the stack. MIN prints the current minimum value in the stack. This is a classic beginner stack problem — track the running minimum as you push elements.

Approach

Given Q operations (PUSH X or MIN), print the current minimum for each MIN operation.

Input

6 PUSH 5 PUSH 3 PUSH 7 MIN POP MIN

Output

3 3
solution.py
Loading editor...
Test 1
Test 2
Test 3

Press Run to test your custom input, or Submit to judge against all test cases.

Sign in to continue

Create a free account to run code, submit solutions and track progress.

  • Free forever — no credit card
  • 10+ languages with live execution
  • Points, streaks & leaderboards
Auto Save OnLn 1, Col 1Spaces: 4UTF-8LFPython 3