Beats 96% users... #Quality Code
\n# Code\n\nclass Solution:\n    def getSmallestString(self, s: str, k: int) -> str:\n        n = len(s)\n        t = list(s)  # Start with t as a copy of s, we
\n# Code\n```\nclass Solution:\n    def getSmallestString(self, s: str, k: int) -> str:\n        n = len(s)\n        t = list(s)  # Start with t as a copy of s, we will modify this list in place\n        for i in range(n):\n            original_char = s[i]\n            cost_to_a = min((ord(original_char) - ord(\'a\')) % 26, (ord(\'a\') - ord(original_char)) % 26)\n            if cost_to_a <= k:\n                t[i] = \'a\'\n                k -= cost_to_a\n            else:\n                t[i] = chr(ord(original_char) - k)\n                \n                break\n\n        return \'\'.join(t)\n```
['Python', 'Python3']