Initialize dp table
for ( let i = 0 ; i < dp . length ; i ++ ) { dp [ i ] = new Array ( 9 * MAX + 1 ) for ( let j = 0 ; j < 9 * MAX + 1 ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } document . write ( countGroups ( 0 , 0 , len , num ) ) ;