computation of dp table similar approach as knapsack problem
for j in range ( 1 , 7 ) : NEW_LINE INDENT cur = 1 NEW_LINE while cur <= j and cur <= len : NEW_LINE INDENT dp [ i ] [ j ] = max ( dp [ i ] [ j ] , dp [ i - 1 ] [ j - cur ] + maxsum [ cur ] ) NEW_LINE cur += 1 NEW_LINE DEDENT DEDENT