Skip to content

Commit 8abe795

Browse files
authored
Update Reverse Queue
1 parent 0cc1e50 commit 8abe795

File tree

1 file changed

+18
-0
lines changed
  • Course 2 - Data Structures in JAVA/Lecture 10 - Queues

1 file changed

+18
-0
lines changed

Course 2 - Data Structures in JAVA/Lecture 10 - Queues/Reverse Queue

+18
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,21 @@ Sample Output 2:
3737
10 1 15 8 2
3838
30 20 10
3939
*/
40+
import java.util.LinkedList;
41+
import java.util.Queue;
42+
43+
public class Solution {
44+
45+
public static void reverseQueue(Queue<Integer> input) {
46+
//Your code goes here
47+
if (input.size()==0 || input.size()==1)
48+
{
49+
return;
50+
}
51+
52+
int temp=input.remove();
53+
reverseQueue(input);
54+
input.add(temp);
55+
}
56+
57+
}

0 commit comments

Comments
 (0)