Back to DSA
Implement Stack using Queues
easyBuild a LIFO stack using only queue operations (enqueue at back, dequeue from front, peek at front, check if empty). Your MyStack class must provide push, pop, top, and empty, behaving identically to a standard stack.
Examples
Example 1:
Input:
MyStack(), push(3), push(7), top(), pop(), empty()Output:
[null,null,null,7,7,false]Hints
1234567