Initialize two array with 0
for ( let i = 0 ; i < n ; i ++ ) { dp [ i ] = new Array ( 2 ) . fill ( 0 ) ; cnt [ i ] = new Array ( 2 ) . fill ( 0 ) ; } for ( let i = 0 ; i < n ; i ++ ) { for ( let j = 0 ; j < 2 ; j ++ ) {