File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12 Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change 1
1
package com .codedifferently .lesson12 ;
2
2
3
+ import java .util .Queue ;
4
+
3
5
public class Lesson12 {
4
6
5
7
/**
6
8
* Provide the solution to LeetCode 3062 here:
7
9
* https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
8
10
*/
9
11
public String gameResult (ListNode head ) {
10
- return null ;
11
12
//make a linked list
12
13
Queue <Integer > queue = new LinkedList <Integer >();
13
14
@@ -24,10 +25,15 @@ public String gameResult(ListNode head) {
24
25
//add a point to "Even" if the even-indexed node is higher
25
26
26
27
// Decide the winner
27
- // compare the points after going through both pairs
28
-
29
- // Return the name of the winning team or "Tie" if points are equal
30
-
28
+ // compare the points and choose the winner or tie
29
+ if (Odd > Even ) {
30
+ return ("Team odd wins!" );
31
+ } else if (Even > Odd ){
32
+ return ("Team Even wins" );
33
+ } else {
34
+ return ("It's a tie" );
35
+ }
36
+
31
37
}
32
38
}
33
39
You can’t perform that action at this time.
0 commit comments