Back to the 100
Problem 079Stack
Easy

Implement Stack using Queues

079

Simulate a stack. Operations are push, pop, top, and empty. Return outputs for pop, top, and empty using 1 for true and 0 for false.

EXAMPLES

Example 1
Input
{
  "operations": [
    "push",
    "push",
    "top",
    "pop",
    "empty"
  ],
  "values": [
    1,
    2,
    0,
    0,
    0
  ]
}

Output
[
  2,
  2,
  0
]

FUNCTION SHAPE

operations: stringArrayvalues: intArrayintArray
00:00
1 local tests readyRun with ⌘/Ctrl + Enter. Your code stays in this browser.

Runs solve(...) locally in a browser worker. SWE Playbook does not submit your code. Only run code you trust; Python code may access the network.