Java - simple char count - back and forth - 3ms
\n\nclass Solution {\n    public String sortString(String s) {\n        int N = s.length();\n        int[] counts = new int[26];\n        int i, total = N;\n   
```\n\nclass Solution {\n    public String sortString(String s) {\n        int N = s.length();\n        int[] counts = new int[26];\n        int i, total = N;\n        \n        for(i = 0; i < N; i++){\n            counts[s.charAt(i) - \'a\']++;\n        }\n        \n        StringBuilder builder = new StringBuilder();\n        \n        boolean forward = true;\n        while(total > 0){\n            if(forward){\n                for(i = 0; i < 26; i++){\n                    if(counts[i] != 0){\n                        builder.append((char)(\'a\' + i));\n                        --counts[i];\n                        --total;\n                    }\n                }\n            }else{\n                for(i = 25; i >= 0; i--){\n                    if(counts[i] != 0){\n                        builder.append((char)(\'a\' + i));\n                        --counts[i];\n                        --total;\n                    }\n                }\n            }\n            \n            forward = !forward;\n        }\n        \n        return builder.toString();\n    }\n}\n\n```
[]