Python | Using dict | Beats 95%
\n\n# Approach\n Describe your approach to solving the problem. \nCreate a frequency map of s.\n\nIterate over all the letters of s in sorted manner and add tha
\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nCreate a frequency map of s.\n\nIterate over all the letters of s in sorted manner and add that character to result .\n\nRepeat above step but for reversed string.\n \nIf the frequency becomes 0 then we delete the key from dict.\n\n# Code\n```\nclass Solution:\n    def sortString(self, s: str) -> str:\n        freq = {}\n        letters = sorted(set(s))\n        res = ""\n        for i in s:\n            if i in freq:\n                freq[i]+=1\n            else:\n                freq[i] = 1\n        while freq:\n            for i in letters:\n                if  i in freq:\n                    if freq[i]>0:\n                        res+=i\n                        freq[i]-=1\n                    else:\n                        del freq[i]\n\n            for i in letters[::-1]:\n                if  i in freq:\n                    if freq[i]>0:\n                        res+=i\n                        freq[i]-=1\n                    else:\n                        del freq[i]\n\n\n        return res\n\n```
['Python3']