Skip to content

Commit 89197d2

Browse files
author
“A1-4U2T1NN”
committed
feat: created lesson 12 game result counter; added comments explaining code;
1 parent 8a39fcc commit 89197d2

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lesson_10/libraries/src/loaders/loaders.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { AnthonyMaysLoader } from './anthony_mays_loader.js';
44
import { JamesCapparellLoader } from './james_capparell_loader.js';
55
import { NileJacksonLoader } from './nile_jackson_loader.js';
66
import { XavierCruzLoader } from './xavier_cruz_loader.js';
7+
import { ChigazoGrahamLoader } from './chigazo_graham_loader.js';
78

89
export const Loaders = Symbol.for('Loaders');
910

@@ -14,6 +15,7 @@ const LOADER_PROVIDERS = [
1415
JamesCapparellLoader,
1516
NileJacksonLoader,
1617
XavierCruzLoader,
18+
ChigazoGrahamLoader,
1719
];
1820

1921
@Module({

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ public class Lesson12 {
77
* https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
88
*/
99
public String gameResult(ListNode head) {
10-
return null;
10+
int evenCounter = 0; //Keeps track of even score
11+
int oddCounter = 0; //Keeps track of odd score
12+
13+
int evenValue = head.val; //Makes the first even value to compare equal to the first number of the list
14+
int oddValue = head.next.val; //Makes the first odd value to compare equal to the second number of the list
15+
16+
if ( evenValue > oddValue ) {
17+
evenCounter = evenCounter + 1;
18+
//Compares the even and odd value, adds 1 to even score if even is greater
19+
} else {
20+
oddCounter = ++oddCounter + 1;
21+
} //Compares the even and odd value, adds 1 to odd score if odd is greater
22+
23+
if (evenCounter > oddCounter) {
24+
return "Even";
25+
//Compares the even and odd score, prints 'Even' if Evens score is greater
26+
} if (evenCounter < oddCounter) {
27+
return "Odd";
28+
//Compares the even and odd score, prints 'Odd' if odds score is greater
29+
} else {
30+
return "Tie";
31+
} //Compares the even and odd score, prints 'Tie' if the two scores are equal
1132
}
1233
}

0 commit comments

Comments
 (0)