Easiest solution using hashmap 100% beat
\n# Complexity\n- Time complexity:O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(26)\n Add your space complexity here, e.g. O(n) \n\n#
\n# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(26)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def sortString(self, s: str) -> str:\n        res=""\n        n=len(s)\n        d=[0]*26\n        for i in s:\n            d[ord(i)-97]+=1\n        while(True):\n            if len(res)==len(s):\n                return res\n            for i in range(26):\n                if d[i]!=0:\n                    temp=chr(i+97)\n                    d[i]-=1\n                    res+=temp\n            for i in range(25,-1,-1):\n                if d[i]!=0:\n                    temp=chr(i+97)\n                    d[i]-=1\n                    res+=temp\n        return res\n            \n```
['Hash Table', 'String', 'Counting', 'Python3']