text: noOfWays [ i ] will store count for value i . 3 extra values are to take care of cornser case n = 0
code: var noOfWays = Array ( n + 3 ) . fill ( 0 ) ; noOfWays [ 0 ] = 1 ; noOfWays [ 1 ] = 1 ; noOfWays [ 2 ] = 1 + 1 ;