Skip to content

Commit 70725b1

Browse files
committed
fix
1 parent 25545fb commit 70725b1

File tree

1 file changed

+17
-23
lines changed
  • lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12

1 file changed

+17
-23
lines changed

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

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,27 @@ public class Lesson12 {
77
* https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
88
*/
99
public String gameResult(ListNode head) {
10-
return null;
11-
}
12-
1310

14-
class Solution {
15-
public String gameResult(ListNode head) {
16-
int[] scores = new int[2];
11+
int[] scores = new int[2];
1712

18-
while (head.next != null) {
19-
// Used ChatGpt to help complete this if statement-starting at the logical & operand
20-
if (head.val != head.next.val && head.val % 2 == 0) {
21-
if (head.val > head.next.val) {
22-
scores[head.val % 2]++;
23-
// Gpt help ended at the line above
24-
} else {
25-
scores[head.next.val % 2]++;
26-
}
13+
while (head.next != null) {
14+
// Used ChatGpt to help complete this if statement-starting at the logical & operand
15+
if (head.val != head.next.val && head.val % 2 == 0) {
16+
if (head.val > head.next.val) {
17+
scores[head.val % 2]++;
18+
// Gpt help ended at the line above
19+
} else {
20+
scores[head.next.val % 2]++;
2721
}
28-
head = head.next;
29-
}
30-
if (scores[0] == scores[1]) {
31-
return "Tie";
32-
} else if (scores[0] > scores[1]) {
33-
return "Even";
34-
} else {
35-
return "odd";
3622
}
23+
head = head.next;
24+
}
25+
if (scores[0] == scores[1]) {
26+
return "Tie";
27+
} else if (scores[0] > scores[1]) {
28+
return "Even";
29+
} else {
30+
return "odd";
3731
}
3832
}
3933
}

0 commit comments

Comments
 (0)