m******r 发帖数: 3 | 1 Dynamic programming
Assuming you have already known if x[n-1] = x1*...*xn-1 can be a, b, or c or not.
Let S[n][j] to be an array, sothat if x[n] can be a, then S[n][1]=1, otherwise 0
if x[n] can be b, then S[n][2]=1, otherwise 0
if x[n] can be c, then S[n][3]=1, otherwise 0
Now move to n, since we have know S[n-1][j], it will be easy to check S[n][j]
That is DP. |
|