File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
lesson_12/structs_java/structs_app/src/main/java/com/codedifferently/lesson12 Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -16,14 +16,13 @@ public String gameResult(ListNode head) {
16
16
int oddValue = head .next .val ; //Makes the first odd value to compare equal to the second number of the list
17
17
18
18
19
- if ( evenValue > oddValue ) {
20
- evenCounter = evenCounter + 1 ;
19
+ if (evenValue > oddValue ) {
20
+ evenCounter ++ ;
21
21
//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 ++ ;
24
24
} //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
27
26
}
28
27
29
28
if (evenCounter > oddCounter ) {
You can’t perform that action at this time.
0 commit comments