10000
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 a811894 commit 77e5402Copy full SHA for 77e5402
src/main/java/com/fishercoder/solutions/_225.java
@@ -8,7 +8,11 @@ public class _225 {
8
public static class Solution1 {
9
class MyStack {
10
11
- Queue<Integer> q = new LinkedList();
+ Queue<Integer> q;
12
+
13
+ public MyStack() {
14
+ q = new LinkedList();
15
+ }
16
17
// Push element x onto stack.
18
public void push(int x) {
@@ -19,8 +23,8 @@ public void push(int x) {
19
23
}
20
24
21
25
// Removes the element on top of the stack.
22
- public void pop() {
- q.poll();
26
+ public int pop() {
27
+ return q.poll();
28
29
30
// Get the top element.
0 commit comments