Skip to content

Commit 59bfb07

Browse files
author
AmiyahJo
committed
chore: remove comments in lesson12.java file
1 parent 1fac40a commit 59bfb07

File tree

1 file changed

+4
-12
lines changed
  • lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12

1 file changed

+4
-12
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,22 @@
22

33
public class Lesson12 {
44

5-
/**
6-
* Provide the solution to LeetCode 3062 here:
7-
* https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
8-
*/
95
public String gameResult(ListNode head) {
10-
//create two variables to count points for "Odd" and "Even"
6+
117
int oddPoints = 0;
128
int evenPoints = 0;
139

14-
// Loop through the linked list to get pairs (so two nodes at a time)
1510
ListNode current = head;
16-
// Check each pair of nodes (odd and even):
17-
// compare their values
18-
while (current != null && current.next != null) {
19-
// add a point to "Even" if the odd-indexed node is higher and vice versa
11+
12+
while (current != null && current.next != null) {
2013
if (current.val > current.next.val){
2114
evenPoints++;
2215
} else if (current.val < current.next.val){
2316
oddPoints++;
2417
}
2518
current = current.next.next;
2619
}
27-
// Decide the winner
28-
// compare the points and choose the winner or tie
20+
2921
if (oddPoints > evenPoints) {
3022
return "Odd";
3123
} else if (evenPoints > oddPoints){

0 commit comments

Comments
 (0)