1
1
package com .codedifferently .lesson12 ;
2
2
3
- import java .util .LinkedList ;
3
+ /* import java.util.LinkedList; */
4
4
import java .util .ArrayList ;
5
+ /* import java.util.List; */
5
6
import java .util .List ;
6
7
7
8
public class Lesson12 {
@@ -10,7 +11,7 @@ public class Lesson12 {
10
11
* Provide the solution to LeetCode 3062 here:
11
12
* https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
12
13
*/
13
- class TeamNode {
14
+ /* class TeamNode {
14
15
int data;
15
16
TeamNode next;
16
17
@@ -34,13 +35,13 @@ public void add(int data) {
34
35
}
35
36
temp.next = newTeamNode;
36
37
}
37
- }
38
+ } */
38
39
39
- public String gameResult (TeamNode head ) {
40
+ public String gameResult (/* Team */ ListNode head ) {
40
41
List <String > result = new ArrayList <>();
41
42
int evenCounter = 0 ;
42
43
int oddCounter = 0 ;
43
- TeamNode current = head ;
44
+ /* Team */ ListNode current = head ;
44
45
45
46
while (current != null && current .next != null ) {
46
47
int evenValue = current .data ;
@@ -66,31 +67,28 @@ public String gameResult(TeamNode head) {
66
67
winningTeam = "tie" ;
67
68
}
68
69
69
- System .out .println ("Nodes with higher values in each pair: " + result );
70
+ System .out .println ("Node team with higher value in each pair: " + result );
70
71
System .out .println ("The team with the most high-values is: " + winningTeam );
71
72
72
73
return winningTeam ;
73
74
}
74
75
}
75
76
76
77
77
- public class Main {
78
+ /* public class Main {
78
79
public static void main(String[] args) {
79
80
LinkedList list = new LinkedList();
80
81
81
- // Adding some nodes to the linked list
82
82
list.add(2);
83
83
list.add(5);
84
84
list.add(4);
85
85
list.add(7);
86
86
list.add(20);
87
87
list.add(5);
88
88
89
- // Call the function to compare pairs and determine the group with the most high-value pairs
90
89
String winningTeam = list.gameResult(list.head);
91
90
92
- // Output the dominant group
93
91
System.out.println("Team with most high-value pairs: " + winningTeam);
94
92
}
95
93
}
96
- }
94
+ } */
0 commit comments