Interview Bootcamp
Ask Author
Back to course home

0% completed

Vote For New Content
Problem 2: Implement Stack using Queues

Problem Statement

Implement a stack using two queues. The stack should support standard operations like push (add an element to the top of the stack) and pop (remove an element from the top of the stack). Examples:

  1. Input: Push operations: [1, 2, 3], Pop operations: 2
    Output: [1]
    Explanation: After pushing 1, 2, 3 the stack looks like [1, 2, 3]. Then we perform 2 pop operations, removing 3 and 2, so the output is [1].

  2. Input: Push operations: [9, 8], Pop operations: 1
    Output: [9]

.....

.....

.....

Like the course? Get enrolled and start learning!