IDFC FIRST Bank interview question

How can you convert a stack into a queue.

Interview Answer

Anonymous

14 Jan 2025

You can use a single stack with recursion to reverse the order. Steps: Push elements onto the stack. When dequeueing: Pop all elements except the last one using recursion. Return the last element (FIFO behavior).