Beats 100% Solutions. Python Greedy Solution.
idea: if k > len(s) * 26, means we got more than enough k, so return "a" * len(s)\n        # if not, make a res string first\n        # now iterate the string, 
# idea: if k > len(s) * 26, means we got more than enough k, so return "a" * len(s)\n        # if not, make a res string first\n        # now iterate the string, and for each char, check distance to get to "a" in both forward and backward \n        # direction, as it is CYCLIC\n        # now if distForward <= distBackward and distForward <= k, means we can go forwards, so go that way and decrement k and also add "a" to res\n        # if distForward > distBackward and distBackward <= k, means we go backwards and reach "a"\n        # else, we simply go backwards as much as possible while k lasts\n        # because the idea is we try to be GREEDY and make the first letters as close to "a" as possible\n        # then the result will always be lexicographically smallest possible\n\n# Code\n```python3 []\nclass Solution:\n    def getSmallestString(self, s: str, k: int) -> str:\n        if k >= len(s) * 26:\n            return "a" * len(s)\n\n        res = ""\n        i = 0\n        while k and i < len(s):\n            distForward = (25 + 1) - (ord(s[i]) - ord(\'a\'))\n            distBackward = ord(s[i]) - ord(\'a\') \n            if distForward <= distBackward and distForward <= k:\n                k -= distForward\n                res += "a"\n            elif distForward > distBackward and distBackward <= k:\n                k -= distBackward\n                res += "a"\n            else:\n                res += chr(ord(s[i]) - k)\n                k = 0\n\n            i += 1\n        \n        if len(res) == len(s): return res\n        else:\n            res += s[len(res)::]\n            return res\n```
['Python3']