Function to initialize the dp and call solveUtil ( ) method to get the answer
function solve ( str , K ) { let N = str . length ; dp = new Array ( N ) ; for ( let i = 0 ; i < N ; i ++ ) { dp [ i ] = new Array ( K ) ; for ( let j = 0 ; j < K ; j ++ ) { dp [ i ] [ j ] = - 1 ; } }