We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ea7f46e commit acc2df0Copy full SHA for acc2df0
lesson_12/structs_ts/src/lesson12.ts
@@ -6,6 +6,28 @@ export class Lesson12 {
6
* https://github.com/yang-su2000/Leetcode-algorithm-practice/tree/master/3062-winner-of-the-linked-list-game
7
*/
8
public gameResult(head: ListNode | null): string {
9
- return '';
+ let ListNode, current = head;
10
+ let even = 0;
11
+ let odd = 0;
12
+ while (current != null && current.next != null) {
13
+ let next: ListNode | null = null;
14
+ if (head === null) {
15
+ odd++;
16
+ }
17
+ if (current.val > nextNode.val) {
18
+ even++;
19
20
+ current === nextNode.next;
21
22
+ if (even > odd) {
23
+ return "Even";
24
25
+ if (even < odd) {
26
+ return "Odd";
27
28
+ if (even === odd) {
29
+ return "Tie";
30
31
+ return null;
32
}
33
0 commit comments