dp [ i ] [ j ] stores whether it is possible to partition first i elements into j segments such that all j segments are 'good
' NEW_LINE INDENT dp = [ [ 0 for i in range ( k + 1 ) ] for i in range ( n + 1 ) ] NEW_LINE DEDENT