【leetcode】上升下降字符串

char * sortString(char * s){
    int hash[26]={0};
    int len = strlen(s);
    int i,pst=0;
    for (i=0; i<len; i++) hash[s[i] - 'a']++;
    while(pst < len)
    {
        for (i=0; i<26; i++)
        {    
            if (hash[i]) {
                s[pst++]=i+'a';
                hash[i]--;
            }
        }
        for (i=25; i>=0; i--)
        {    
            if (hash[i]) {
                s[pst++]=i+'a';
                hash[i]--;
            }
        }        
    }
    return s;
}
原文地址:https://www.cnblogs.com/ganxiang/p/13731522.html