int min;
void dfs(char* s,int head,int tail, int count){
if(head>=tail){
if(count<min) min=count;
return ;
}
if(s[head]==s[tail]){
dfs(s,head+1,tail-1,count);
}else{
dfs(s,head+1,tail,count+1);
dfs(s,head,tail-1,count+1);
}
}
int minInsertions(char* s) {
int n=strlen(s);
if(n==1) return 0;
min=INT_MAX;
int head=0,tail=n-1,count=0;
dfs(s,head,tail,count);
if(min== INT_MAX) min=0;
return min;
}
标签:count,head,1312,int,tail,字符串,回文
From: https://www.cnblogs.com/llllmz/p/18085552