[Java] Bucket Sort and Keep Frequency
\n    public String sortString(String s) {\n        int[] freq = new int[26];\n        for(char c : s.toCharArray()){\n            freq[c-\'a\']++;\n        }\n
```\n    public String sortString(String s) {\n        int[] freq = new int[26];\n        for(char c : s.toCharArray()){\n            freq[c-\'a\']++;\n        }\n        StringBuilder sb = new StringBuilder();\n        while(sb.length()<s.length()){\n            for(int i=0; i<26; i++){\n                if(freq[i]>0){\n                    sb.append((char)(\'a\'+i));\n                    freq[i]--;\n                }\n            }\n            for(int i=25; i>=0; i--){\n                if(freq[i]>0){\n                    sb.append((char)(\'a\'+i));\n                    freq[i]--;\n                }\n            }\n        }\n        return sb.toString();\n    }\n```
[]