Driver Code to test above function
let W = 3 , K = 3 , M = 2 ; let dp = new Array ( W + 1 ) ; for ( let i = 0 ; i < W + 1 ; i ++ ) { dp [ i ] = new Array ( 2 ) ; for ( let j = 0 ; j < 2 ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } document . write ( solve ( dp , W , K , M , 0 ) + " " ) ;