Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 452 Bytes

Ex_1_3_06.md

File metadata and controls

33 lines (23 loc) · 452 Bytes
title date draft tags categories
Algorithm4 Java Solution 1.3.06
2019-07-04 05:47:10 +0800
false
JAVA
TECH
archives

1.3.06

Problem:

What does the following code fragment do to the queue q?

Stack<String> stack = new Stack<String>();
while(!q.isEmpty())
    stack.push(q.dequeue());
while(!stack.isEmpty())
    q.enqueue(stack.pop());

Solution:

reverse the elements order in q.

Reference: