Simple java code 2 ms beats 100 %
Complexity\n\n# Code\n\nclass Solution {\n    public String sortString(String s) {\n        int arr[]=new int[26];\n        for(char c: s.toCharArray()){\n     
# Complexity\n![image.png](https://assets.leetcode.com/users/images/d1479de3-4415-4327-b954-f4b15154d134_1711346790.9053507.png)\n# Code\n```\nclass Solution {\n    public String sortString(String s) {\n        int arr[]=new int[26];\n        for(char c: s.toCharArray()){\n            arr[c-\'a\']++;\n        }\n        StringBuilder sb=new StringBuilder();\n        while(true){\n            boolean flag=true;\n            for(int i=0;i<26;i++){\n                if(arr[i]!=0){\n                    flag=false;\n                    sb.append((char)(\'a\'+i));\n                    arr[i]--;\n                }\n            }\n            for(int i=25;i>=0;i--){\n                if(arr[i]!=0){\n                    flag=false;\n                    sb.append((char)(\'a\'+i));\n                    arr[i]--;\n                }\n            }\n            if(flag)    break;\n        }\n        return sb.toString();\n    }\n}\n```
['Hash Table', 'String', 'Counting', 'Java']