Skip to content

Commit 77e5402

Browse files
refaactor 225 for updated signature per LeetCode
1 parent a811894 commit 77e5402

File tree

1 file changed

+7
-3
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+7
-3
lines changed

src/main/java/com/fishercoder/solutions/_225.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ public class _225 {
88
public static class Solution1 {
99
class MyStack {
1010

11-
Queue<Integer> q = new LinkedList();
11+
Queue<Integer> q;
12+
13+
public MyStack() {
14+
q = new LinkedList();
15+
}
1216

1317
// Push element x onto stack.
1418
public void push(int x) {
@@ -19,8 +23,8 @@ public void push(int x) {
1923
}
2024

2125
// Removes the element on top of the stack.
22-
public void pop() {
23-
q.poll();
26+
public int pop() {
27+
return q.poll();
2428
}
2529

2630
// Get the top element.

0 commit comments

Comments
 (0)