File tree Expand file tree Collapse file tree 2 files changed +15
-17
lines changed Expand file tree Collapse file tree 2 files changed +15
-17
lines changed Original file line number Diff line number Diff line change @@ -9,29 +9,29 @@ export class Lesson12 {
9
9
let e_pts = 0 ;
10
10
let o_pts = 0 ;
11
11
12
- if ( head === null ) {
13
- return "" ;
12
+ if ( head === null ) {
13
+ return '' ;
14
14
}
15
15
16
16
let curr : ListNode | undefined = head ;
17
17
18
18
while ( curr != null ) {
19
- let next : ListNode | undefined = curr . next ;
20
- if ( next === undefined ) {
21
- return "" ;
19
+ const next : ListNode | undefined = curr . next ;
20
+ if ( next === undefined ) {
21
+ return '' ;
22
22
}
23
- if ( curr . val > next ! . val ) {
23
+ if ( curr . val > next ? .val ) {
24
24
e_pts ++ ;
25
- } else if ( curr . val < next ! . val ) {
25
+ } else if ( curr . val < next ? .val ) {
26
26
o_pts ++ ;
27
27
}
28
28
curr = next . next ;
29
29
}
30
30
31
31
if ( e_pts === o_pts ) {
32
- return " Tie" ;
32
+ return ' Tie' ;
33
33
}
34
34
35
- return e_pts > o_pts ? " Even" : " Odd" ;
35
+ return e_pts > o_pts ? ' Even' : ' Odd' ;
36
36
}
37
37
}
Original file line number Diff line number Diff line change @@ -8,20 +8,19 @@ export class Stack {
8
8
}
9
9
10
10
push ( value : number ) : void {
11
- let node : ListNode | undefined = new ListNode ( value ) ;
11
+ const node : ListNode | undefined = new ListNode ( value ) ;
12
12
13
13
node . next = this . top ;
14
14
this . top = node ;
15
-
16
15
}
17
16
18
17
pop ( ) : number | undefined {
19
- if ( this . isEmpty ( ) ) {
18
+ if ( this . isEmpty ( ) ) {
20
19
throw new Error ( 'Stack is empty' ) ;
21
20
}
22
21
23
- if ( this . top ) {
24
- let value_to_pop : number = this . top . val
22
+ if ( this . top ) {
23
+ const value_to_pop : number = this . top . val ;
25
24
this . top = this . top . next ;
26
25
return value_to_pop ;
27
26
}
@@ -30,16 +29,15 @@ export class Stack {
30
29
}
31
30
32
31
peek ( ) : number | null {
33
- if ( this . isEmpty ( ) ) {
32
+ if ( this . isEmpty ( ) ) {
34
33
throw new Error ( 'Stack is empty' ) ;
35
34
}
36
35
37
- if ( this . top ) {
36
+ if ( this . top ) {
38
37
return this . top . val ;
39
38
}
40
39
41
40
return null ;
42
-
43
41
}
44
42
45
43
isEmpty ( ) : boolean {
You can’t perform that action at this time.
0 commit comments