Skip to content

Commit a0d650e

Browse files
author
“A1-4U2T1NN”
committed
chore: simplified counter incraments; fix: changed head.next to head.next.next;
1 parent 0362fcb commit a0d650e

File tree

1 file changed

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

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ public String gameResult(ListNode head) {
1616
int oddValue = head.next.val; //Makes the first odd value to compare equal to the second number of the list
1717

1818

19-
if ( evenValue > oddValue ) {
20-
evenCounter = evenCounter + 1;
19+
if (evenValue > oddValue) {
20+
evenCounter++;
2121
//Compares the even and odd value, adds 1 to even score if even is greater
22-
} else {
23-
oddCounter = oddCounter + 1;
22+
} else if (evenValue < oddValue) {
23+
oddCounter++;
2424
} //Compares the even and odd value, adds 1 to odd score if odd is greater
25-
// head.val = head.next.val; //Brings out the next pair befor restarting the loop
26-
head = head.next; //Brings out the next pair befor restarting the loop
25+
head = head.next.next; //Brings out the next pair befor restarting the loop
2726
}
2827

2928
if (evenCounter > oddCounter) {

0 commit comments

Comments
 (0)