We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0cc1e50 commit 8abe795Copy full SHA for 8abe795
Course 2 - Data Structures in JAVA/Lecture 10 - Queues/Reverse Queue
@@ -37,3 +37,21 @@ Sample Output 2:
37
10 1 15 8 2
38
30 20 10
39
*/
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