Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@

public class Lesson12 {

public Lesson12() {}

/**
* Provide the solution to LeetCode 3062 here:
* https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
*/
public String gameResult(ListNode head) {
return null;
var o = 0;
var e = 0;
while (head != null) {
if (head.val > head.next.val) {
e++;
} else {
o++;
}
head = head.next.next;
}
if (e > o) {
return "Even";
} else if (e < o) {
return "Odd";
} else return "Tie";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@ public Stack() {
}

public void push(int value) {
// Your code here
ListNode newTop = new ListNode(value);
newTop.next = top;
top = newTop;
}

public int pop() {
return 0;
var oldTop = top.val;
top = top.next;
return oldTop;
}

public int peek() {
return 0;
var headVal = top.val;
return headVal;
}

public boolean isEmpty() {
return true;
return top == null;
}
}