File tree Expand file tree Collapse file tree 1 file changed +17
-23
lines changed
lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12 Expand file tree Collapse file tree 1 file changed +17
-23
lines changed Original file line number Diff line number Diff line change @@ -7,33 +7,27 @@ public class Lesson12 {
7
7
* https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
8
8
*/
9
9
public String gameResult (ListNode head ) {
10
- return null ;
11
- }
12
-
13
10
14
- class Solution {
15
- public String gameResult (ListNode head ) {
16
- int [] scores = new int [2 ];
11
+ int [] scores = new int [2 ];
17
12
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 ]++;
27
21
}
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" ;
36
22
}
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" ;
37
31
}
38
32
}
39
33
}
You can’t perform that action at this time.
0 commit comments