Skip to content

Commit c0545ad

Browse files
author
AmiyahJo
committed
feat: adds if else statement on whether one of the teams win or if its a tie
1 parent 710b3c1 commit c0545ad

File tree

1 file changed

+11
-5
lines changed
  • lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package com.codedifferently.lesson12;
22

3+
import java.util.Queue;
4+
35
public class Lesson12 {
46

57
/**
68
* Provide the solution to LeetCode 3062 here:
79
* https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
810
*/
911
public String gameResult(ListNode head) {
10-
return null;
1112
//make a linked list
1213
Queue<Integer> queue = new LinkedList<Integer>();
1314

@@ -24,10 +25,15 @@ public String gameResult(ListNode head) {
2425
//add a point to "Even" if the even-indexed node is higher
2526

2627
// 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+
3137
}
3238
}
3339

0 commit comments

Comments
 (0)