We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 678f89d commit d56755bCopy full SHA for d56755b
src/MyQueue.java
@@ -0,0 +1,27 @@
1
+import java.util.LinkedList;
2
+import java.util.Queue;
3
+
4
+public class MyQueue {
5
6
+ Queue<Integer> queue = new LinkedList<>();
7
8
+ /** Push element x to the back of queue. */
9
+ public void push(int x) {
10
+ queue.add(x);
11
+ }
12
13
+ /** Removes the element from in front of queue and returns that element. */
14
+ public int pop() {
15
+ return queue.poll();
16
17
18
+ /** Get the front element. */
19
+ public int peek() {
20
+ return queue.peek();
21
22
23
+ /** Returns whether the queue is empty. */
24
+ public boolean empty() {
25
+ return queue.isEmpty();
26
27
+}
0 commit comments