Skip to content

Commit 4a4e6fa

Browse files
author
AmiyahJo
committed
feat: adjusts .java code to typescript language
1 parent 39db8a2 commit 4a4e6fa

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

lesson_12/structs_ts/src/lesson12.ts

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,20 @@ export class Lesson12 {
66
* https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
77
*/
88
public gameResult(head: ListNode | null): string {
9-
const oddPoints = 0;
10-
const evenPoints = 0;
9+
let oddPoints = 0;
10+
let evenPoints = 0;
1111

12-
// ListNode current = head;
13-
class ListNode {
14-
current: null | undefined;
15-
costructor(head = null) {
16-
this.current = head;
12+
let current = head;
13+
14+
while(current != null && current.next != null) {
15+
if (current.val > current.next.val) {
16+
evenPoints++;
17+
} else if (current.val < current.next.val) {
18+
oddPoints++;
1719
}
20+
// current = current.next.next;
1821
}
1922

20-
// while(current != null && current.next != null) {
21-
// if (current.val > current.next.val) {
22-
// evenPoints++;
23-
// } else if (current.val < current.next.val) {
24-
// oddPoints++;
25-
// }
26-
// current = current.next.next;
27-
// }
28-
2923
if (oddPoints > evenPoints) {
3024
return "Odd";
3125
} else if (evenPoints > oddPoints) {

0 commit comments

Comments
 (0)