【leetcode】整理字符串

 

char * makeGood(char * s){
    int pst=0,i,len=strlen(s);
    for (i=1; i<len; i++)
    {
        if (pst>=0 && abs(s[pst]-s[i]) == 32) pst--;
        else s[++pst] = s[i];
    }
    s[pst+1] = '\0';
    return s;
}

 

posted @ 2020-09-21 11:37  温暖了寂寞  阅读(92)  评论(0编辑  收藏  举报