Easy
079Implement Stack using Queues
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: intArray→intArray