Skip to content

Commit edea678

Browse files
committed
fix: ran spotlessApply
1 parent d7025aa commit edea678

File tree

4 files changed

+49
-47
lines changed

4 files changed

+49
-47
lines changed

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,30 @@ public class Lesson12 {
66
* Provide the solution to LeetCode 3062 here:
77
* https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
88
*/
9-
public String gameResult(ListNode head) {
10-
int oddPoints = 0;
11-
int evenPoints = 0;
12-
ListNode current = head;
13-
14-
while (current != null && current.next != null) {
15-
int evenValue = current.val;
16-
int oddValue = current.next.val;
17-
18-
if (evenValue > oddValue) {
19-
evenPoints++;
20-
} else if (oddValue > evenValue) {
21-
oddPoints++;
22-
}
9+
public String gameResult(ListNode head) {
10+
int oddPoints = 0;
11+
int evenPoints = 0;
12+
ListNode current = head;
2313

24-
current = current.next.next;
25-
}
26-
27-
if (evenPoints > oddPoints) {
28-
return "Even";
29-
} else if (oddPoints > evenPoints) {
30-
return "Odd";
31-
} else {
32-
return "Tie";
33-
}
14+
while (current != null && current.next != null) {
15+
int evenValue = current.val;
16+
int oddValue = current.next.val;
17+
18+
if (evenValue > oddValue) {
19+
evenPoints++;
20+
} else if (oddValue > evenValue) {
21+
oddPoints++;
22+
}
23+
24+
current = current.next.next;
25+
}
26+
27+
if (evenPoints > oddPoints) {
28+
return "Even";
29+
} else if (oddPoints > evenPoints) {
30+
return "Odd";
31+
} else {
32+
return "Tie";
3433
}
35-
}
34+
}
35+
}

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

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,29 @@ public Stack() {
99
}
1010

1111
public void push(int value) {
12-
ListNode node = new ListNode(value);
13-
node.next = top;
14-
top = node;
15-
}
12+
ListNode node = new ListNode(value);
13+
node.next = top;
14+
top = node;
15+
}
1616

17-
public int pop() {
18-
if (isEmpty()){
19-
throw new IllegalStateException("Stack has no values");
20-
}
21-
int valToPop = top.val;
22-
top = top.next;
23-
return valToPop;
24-
}
17+
public int pop() {
18+
if (isEmpty()) {
19+
throw new IllegalStateException("Stack has no values");
20+
}
21+
int valToPop = top.val;
22+
top = top.next;
23+
return valToPop;
24+
}
2525

26-
public int peek() {
27-
if (isEmpty()){
28-
throw new IllegalStateException("Stack has no values");
29-
}
26+
public int peek() {
27+
if (isEmpty()) {
28+
throw new IllegalStateException("Stack has no values");
29+
}
3030

31-
return top.val;
32-
}
31+
return top.val;
32+
}
3333

34-
public boolean isEmpty() {
35-
return top == null;
36-
}
37-
}
34+
public boolean isEmpty() {
35+
return top == null;
36+
}
37+
}

lesson_12/structs_java/structs_app/src/test/java/com/codedifferently/lesson12/Lesson12Test.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.codedifferently.lesson12;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
45
import org.junit.jupiter.api.Test;
56

67
class Lesson12Test {

lesson_12/structs_java/structs_app/src/test/java/com/codedifferently/lesson12/StackTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static org.junit.jupiter.api.Assertions.assertFalse;
55
import static org.junit.jupiter.api.Assertions.assertThrows;
66
import static org.junit.jupiter.api.Assertions.assertTrue;
7+
78
import org.junit.jupiter.api.Test;
89

910
class StackTest {

0 commit comments

Comments
 (0)