File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed
src/hackerrank/interview_preparation_kit/arrays Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change 33 */
44
55function gethourGlass ( arr , positionX , positionY ) {
6- const result = [ ] ;
7-
8- // top
9- result . push ( arr [ positionX - 1 ] [ positionY - 1 ] ) ;
10- result . push ( arr [ positionX - 1 ] [ positionY ] ) ;
11- result . push ( arr [ positionX - 1 ] [ positionY + 1 ] ) ;
12- // middle
13- result . push ( arr [ positionX ] [ positionY ] ) ;
14- // bottom
15- result . push ( arr [ positionX + 1 ] [ positionY - 1 ] ) ;
16- result . push ( arr [ positionX + 1 ] [ positionY ] ) ;
17- result . push ( arr [ positionX + 1 ] [ positionY + 1 ] ) ;
18- return result ;
6+ return [
7+ // top
8+ arr [ positionX - 1 ] [ positionY - 1 ] ,
9+ arr [ positionX - 1 ] [ positionY ] ,
10+ arr [ positionX - 1 ] [ positionY + 1 ] ,
11+ // middle
12+ arr [ positionX ] [ positionY ] ,
13+ // bottom
14+ arr [ positionX + 1 ] [ positionY - 1 ] ,
15+ arr [ positionX + 1 ] [ positionY ] ,
16+ arr [ positionX + 1 ] [ positionY + 1 ]
17+ ] ;
1918}
2019
2120function hourglassSum ( arr ) {
You can’t perform that action at this time.
0 commit comments