【leetcode】删除字符串中的所有相邻重复项

char * removeDuplicates(char * S){
int top=-1;
int i;
int len=strlen(S);
for(i=0;i<len;i++){
    S[++top]=S[i];//入栈
    if(top>0&&S[top]==S[top-1]){
        top=top-2;
    }
}
S[top+1]='';
return S;
}
原文地址:https://www.cnblogs.com/ganxiang/p/13638302.html