|
|
back to boardDP solution Posted by MSDN 9 Mar 2008 18:26 S - it is a line Create a matrix F[i][j] is a decision with i on j a symbol If S[i] it is a closing bracket, F[i][j] =1 + F[i+1][j] If S[i] a closing bracket that is two cases: 1) We add a closing bracket - 1 + min(F[i+1][k] + F[k+1][j]), where i<k<=j 2) Is in line closing - min(F[i+1][k-1], F[k+1][j]), where S[k] = S[i] and i<k<=j Re: DP solution Interesting... But what you output? Please explain to me Re: DP solution Posted by hoan 26 Nov 2010 00:00 > 1) We add a closing bracket - 1 + min(F[i+1][k] + F[k+1][j]), where i<k<=j if we want to add a bracket we can add it in (i+1)position. and dont necessary too check all the kind. sorry for my poor english. GOOD LUCK!!! |
|
|