Hello all, I am trying to understand the algorithm mentioned in the editorial for the following problem
Zuma Here is its editorial editorial.
In the case, when the ith color matches with the kth color in the range [i...j], shouldn't we be doing
D[i][j] = D[i+1][k-1] + D[k+1][j] + 1, instead of
D[i][j] = D[i+1][k-1] + D[k+1][j]
?
This is because, we have to destroy the matching characters in ith position with kth position also, which will take 1 step extra.