Simple Intuitive Greedy (Beats 70% TE and 70% ME)
Intuition\n- We need to find the first occurence of \'a\' - all alphabets before that can be reduced by 1 and next remains same for lexicographically smallest s
# Intuition\n- We need to find the first occurence of \'a\' - all alphabets before that can be reduced by 1 and next remains same for lexicographically smallest string\n- ***A lexicographically smallest string can be greedily formed if the beginning alphabets are smallest possible***\n\n# Approach\n- Below are the corner cases to handle :\n    - What if the string starts with \'a\'? We find the next position of all \'a\'\'s and start reducing from there till next occurence of \'a\'.\n    - What if string only has \'a\'? Then we have to make the last alphabet \'z\'\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution:\n    def smallestString(self, s: str) -> str:\n        if len(s)==s.count(\'a\'): return \'a\'*(len(s)-1)+\'z\'\n        res = ""\n        j=0\n        while s[j]==\'a\':\n            j += 1\n            res+="a"\n        for i in range(j, len(s)):\n            if s[i]==\'a\':\n               res+=s[i:]\n               break\n\n            res+=chr(ord(s[i])-1)\n\n        return res\n        \n```
['Greedy', 'Python3']