File tree Expand file tree Collapse file tree 3 files changed +18
-19
lines changed
interview_preparation_kit/arrays Expand file tree Collapse file tree 3 files changed +18
-19
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,7 @@ function countApplesAndOranges(
2525 }
2626 }
2727
28- const result : number [ ] = [ ] ;
29- result . push ( cApples ) ;
30- result . push ( cOranges ) ;
28+ const result : number [ ] = [ cApples , cOranges ] ;
3129
3230 return result . join ( '\n' ) ;
3331}
Original file line number Diff line number Diff line change @@ -7,18 +7,19 @@ function gethourGlass(
77 positionX : number ,
88 positionY : number
99) : number [ ] {
10- const result : number [ ] = [ ] ;
10+ const result : number [ ] = [
11+ // top
12+ arr [ positionX - 1 ] [ positionY - 1 ] ,
13+ arr [ positionX - 1 ] [ positionY ] ,
14+ arr [ positionX - 1 ] [ positionY + 1 ] ,
15+ // middle
16+ arr [ positionX ] [ positionY ] ,
17+ // bottom
18+ arr [ positionX + 1 ] [ positionY - 1 ] ,
19+ arr [ positionX + 1 ] [ positionY ] ,
20+ arr [ positionX + 1 ] [ positionY + 1 ]
21+ ] ;
1122
12- // top
13- result . push ( arr [ positionX - 1 ] [ positionY - 1 ] ) ;
14- result . push ( arr [ positionX - 1 ] [ positionY ] ) ;
15- result . push ( arr [ positionX - 1 ] [ positionY + 1 ] ) ;
16- // middle
17- result . push ( arr [ positionX ] [ positionY ] ) ;
18- // bottom
19- result . push ( arr [ positionX + 1 ] [ positionY - 1 ] ) ;
20- result . push ( arr [ positionX + 1 ] [ positionY ] ) ;
21- result . push ( arr [ positionX + 1 ] [ positionY + 1 ] ) ;
2223 return result ;
2324}
2425
Original file line number Diff line number Diff line change @@ -17,11 +17,11 @@ function plusMinus(arr: number[]): string {
1717 }
1818 }
1919
20- const result : string [ ] = [ ] ;
21-
22- result . push ( ( positives / arr . length ) . toFixed ( 6 ) ) ;
23- result . push ( ( negatives / arr . length ) . toFixed ( 6 ) ) ;
24- result . push ( ( zeros / arr . length ) . toFixed ( 6 ) ) ;
20+ const result : string [ ] = [
21+ ( positives / arr . length ) . toFixed ( 6 ) ,
22+ ( negatives / arr . length ) . toFixed ( 6 ) ,
23+ ( zeros / arr . length ) . toFixed ( 6 )
24+ ] ;
2525
2626 return result . join ( `\n` ) ;
2727}
You can’t perform that action at this time.
0 commit comments