Skip to content

Commit 0cc24ba

Browse files
committed
Feat: fix to .ts files
1 parent 3824f05 commit 0cc24ba

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

lesson_12/structs_ts/src/lesson12.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,36 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
12
import { ListNode } from './list_node.js';
23

34
export class Lesson12 {
5+
push(scores: number): void {
6+
throw new Error('Not implemented');
7+
}
48
/**
59
* Provide the solution to LeetCode 3062 here:
610
* https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
711
*/
8-
public gameResult(head: ListNode | null): String {
9-
if (!head) return "Tie";
10-
11-
12-
let current: ListNode | null = head;
13-
const scores: number[] = [0, 0];
14-
15-
while (current && current.next) {
12+
public gameResult(head: ListNode | null): string {
13+
if (!head) return 'Tie';
14+
15+
let current: ListNode | null = head;
16+
const scores: number[] = [0, 0];
17+
18+
while (current && current.next) {
1619
if (current.val !== current.next.val && current.val % 2 == 0) {
1720
if (current.val > current.next.val) {
1821
scores[0]++;
19-
} else {
20-
scores[1]++;
21-
}
22+
} else {
23+
scores[1]++;
24+
}
2225
}
2326
current = current.next;
2427
}
25-
if(scores[0] > scores[1]) {
26-
return "Even";
27-
} else if (scores[0] < scores[1]) {
28-
return "Odd";
29-
} else {
30-
return "Tie";
28+
if (scores[0] > scores[1]) {
29+
return 'Even';
30+
} else if (scores[0] < scores[1]) {
31+
return 'Odd';
32+
} else {
33+
return 'Tie';
34+
}
3135
}
3236
}
33-
}
34-

0 commit comments

Comments
 (0)