File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -7,17 +7,16 @@ export class Lesson12 {
7
7
*/
8
8
public gameResult ( head : ListNode | null ) : string {
9
9
let [ oddPoints , evenPoints ] = [ 0 , 0 ] ;
10
-
11
10
let current = head ;
12
11
13
- // while(current != null && current.next != null) {
14
- // if (current.val > current.next.val) {
15
- // evenPoints++;
16
- // } else if (current.val < current.next.val) {
17
- // oddPoints++;
18
- // }
19
- // current = current.next.next;
20
- // }
12
+ while ( current != null && current . next != null ) {
13
+ if ( current . val > current . next . val ) {
14
+ evenPoints ++ ;
15
+ } else if ( current . val < current . next . val ) {
16
+ oddPoints ++ ;
17
+ }
18
+ current = current . next ? current . next . next || null : null ;
19
+ }
21
20
22
21
if ( oddPoints > evenPoints ) {
23
22
return "Odd" ;
You can’t perform that action at this time.
0 commit comments