225. Implement Stack Using Queues

Practice Implement Stack Using Queues for free on NudgeCode: Easy, Stack pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Build a last-in-first-out stack using only queue operations (add to back, remove from front, look at front, size, is empty).

Each test is a list of operations and their arguments; the expected output lists what each call returns (null for calls that return nothing).

Example

["MyStack","push","push","top","pop","empty"]
[[],[1],[2],[],[],[]]
->  [null,null,null,2,2,false]

Constraints