原题题目
代码实现(首刷自解)
int minInsertions(char * s){
int dp[501][501],start,end,strl = strlen(s);memset(dp,0,sizeof(dp));for(end=1;end<strl;end++){
for(start=end-1;start>=0;start--){
if(s[start] == s[end]){
if(end == start + 1) dp[start][end] = 0;else dp[start][end] = dp[start+1][end-1];}else dp[start][end] = fmin(dp[start][end-1] + 1,dp[start+1][end] + 1);}}return dp[0][strl-1];
}