Skip to content

Commit af94104

Browse files
author
Meiko-S22
committed
feat: adds Meiko's lesson 12
1 parent b41b553 commit af94104

File tree

1 file changed

+8
-5
lines changed
  • lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12

1 file changed

+8
-5
lines changed

lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12/Stack.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,22 @@ public Stack() {
99
}
1010

1111
public void push(int value) {
12-
// your code
13-
12+
ListNode newNode = new ListNode(value);
13+
newNode.next = top;
14+
top = newNode;
1415
}
1516

1617
public int pop() {
17-
return 0;
18+
int value = top.val;
19+
top = top.next;
20+
return value;
1821
}
1922

2023
public int peek() {
21-
return 0;
24+
return top.val;
2225
}
2326

2427
public boolean isEmpty() {
25-
return true;
28+
return top == null;
2629
}
2730
}

0 commit comments

Comments
 (0)