Kotlinlearncs.online LogoJava
Return to List

Solve: Reverse Stack with Queue

Created By: Justin Maier
/ Version: 2024.10.0

Complete the method below that reverses the order of elements in a Stack<Integer>. Use a Queue to accomplish this. Our Queue has the following interface.

Additionally, you are provided with an implementation of the MyQueue named ArrayListQueue. This queue does not have a fixed capacity. You can create a new instance of the queue with MyQueue<Integer> q = new ArrayListQueue<>();.

Additionally, if the passed stack is null, throw an IllegalArgumentException.

void reverseStack(Stack<Integer> stack) {
return; // You may need to remove this starter code
}

Related Lessons

Stuck? You may find these lessons helpful: