Skip to content

Commit 6b95e3b

Browse files
author
“A1-4U2T1NN”
committed
fix: corrected formating in lesson 12 assignments;
1 parent a0d650e commit 6b95e3b

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

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

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,40 @@
22

33
public class Lesson12 {
44

5-
6-
/**
7-
* Provide the solution to LeetCode 3062 here:
8-
* https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
9-
*/
10-
public String gameResult(ListNode head) {
11-
int evenCounter = 0; //Keeps track of even score
12-
int oddCounter = 0; //Keeps track of odd score
13-
14-
while(head != null && head.next != null) { //Goes through the Linked List until theres no more pairs
15-
int evenValue = head.val; //Makes the first even value to compare equal to the first number of the list
16-
int oddValue = head.next.val; //Makes the first odd value to compare equal to the second number of the list
17-
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+
*/
9+
public String gameResult(ListNode head) {
10+
int evenCounter = 0; // Keeps track of even score
11+
int oddCounter = 0; // Keeps track of odd score
12+
13+
while (head != null
14+
&& head.next != null) { // Goes through the Linked List until theres no more pairs
15+
int evenValue =
16+
head.val; // Makes the first even value to compare equal to the first number of the list
17+
int oddValue =
18+
head.next
19+
.val; // Makes the first odd value to compare equal to the second number of the list
1820

1921
if (evenValue > oddValue) {
2022
evenCounter++;
21-
//Compares the even and odd value, adds 1 to even score if even is greater
23+
// Compares the even and odd value, adds 1 to even score if even is greater
2224
} else if (evenValue < oddValue) {
2325
oddCounter++;
24-
} //Compares the even and odd value, adds 1 to odd score if odd is greater
25-
head = head.next.next; //Brings out the next pair befor restarting the loop
26+
} // Compares the even and odd value, adds 1 to odd score if odd is greater
27+
head = head.next.next; // Brings out the next pair befor restarting the loop
2628
}
2729

28-
if (evenCounter > oddCounter) {
29-
return "Even";
30-
//Compares the even and odd score, prints 'Even' if Evens score is greater
31-
} if (evenCounter < oddCounter) {
32-
return "Odd";
33-
//Compares the even and odd score, prints 'Odd' if odds score is greater
34-
} else {
35-
return "Tie";
36-
} //Compares the even and odd score, prints 'Tie' if the two scores are equal
37-
30+
if (evenCounter > oddCounter) {
31+
return "Even";
32+
// Compares the even and odd score, prints 'Even' if Evens score is greater
33+
}
34+
if (evenCounter < oddCounter) {
35+
return "Odd";
36+
// Compares the even and odd score, prints 'Odd' if odds score is greater
37+
} else {
38+
return "Tie";
39+
} // Compares the even and odd score, prints 'Tie' if the two scores are equal
3840
}
39-
4041
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ public void push(int value) {
1616

1717
public int pop() {
1818
int newTop = 0;
19-
if(isEmpty()){
19+
if (isEmpty()) {
2020
throw new IllegalStateException("Stack is empty");
21-
}else{
21+
} else {
2222
newTop = top.val;
2323
top = top.next;
2424
return newTop;
2525
}
2626
}
2727

2828
public int peek() {
29-
if(isEmpty()){
29+
if (isEmpty()) {
3030
throw new IllegalStateException("Stack is empty");
3131
}
3232
return top.val;

0 commit comments

Comments
 (0)