Skip to content

Commit 4a95f7b

Browse files
add 3062
1 parent 4c4c914 commit 4a95f7b

File tree

2 files changed

+29
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src/main/java/com/fishercoder/solutions/fourththousand

2 files changed

+29
-0
lines changed

paginated_contents/algorithms/4th_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
| 3127 | [Make a Square with the Same Color](https://leetcode.com/problems/make-a-square-with-the-same-color/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3127.java) | | Easy |
2828
| 3120 | [Count the Number of Special Characters I](https://leetcode.com/problems/count-the-number-of-special-characters-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3120.java) | | Easy |
2929
| 3110 | [Score of a String](https://leetcode.com/problems/score-of-a-string/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3110.java) | | Easy |
30+
| 3062 | [Winner of the Linked List Game](https://leetcode.com/problems/winner-of-the-linked-list-game/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3062.java) | | Easy |
3031
| 3046 | [Split the Array](https://leetcode.com/problems/split-the-array/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3046.java) | | Easy |
3132
| 3042 | [Count Prefix and Suffix Pairs I](https://leetcode.com/problems/count-prefix-and-suffix-pairs-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3042.java) | | Easy |
3233
| 3038 | [Maximum Number of Operations With the Same Score I](https://leetcode.com/problems/maximum-number-of-operations-with-the-same-score-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3038.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
import com.fishercoder.common.classes.ListNode;
4+
5+
public class _3062 {
6+
public static class Solution1 {
7+
public String gameResult(ListNode head) {
8+
int oddPoints = 0;
9+
int evenPoints = 0;
10+
ListNode even = head;
11+
ListNode odd = head.next;
12+
while (odd != null && even != null) {
13+
if (even.val > odd.val) {
14+
evenPoints++;
15+
} else {
16+
oddPoints++;
17+
}
18+
if (even.next != null && odd.next != null) {
19+
even = even.next.next;
20+
odd = odd.next.next;
21+
} else {
22+
break;
23+
}
24+
}
25+
return evenPoints > oddPoints ? "Even" : evenPoints == oddPoints ? "Tie" : "Odd";
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)