✅Easy | Beats 100% | Begineer Friendly | Explained💯
 # Intuition  \n\n\n\n\n\n# Complexity\n- Time complexity:O(n)\n\n\n- Space complexity: O(1)\n\n\n# Code\n\npython []\nclass Solution:\n    def getSmallestStrin
<!-- # Intuition -->\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n<!-- # Approach -->\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n\n```python []\nclass Solution:\n    def getSmallestString(self, s: str, k: int) -> str:\n        res = ""\n        for char in s:\n            # Calculate the distance to the closest character\n            min_d = min(ord(char) - ord(\'a\'), ord(\'z\') - ord(char) + 1)\n            # If the total distance exceeds k, prioritize changing characters\n            if k >= min_d:\n                k -= min_d\n                res += \'a\' if min_d <= ord(char) - ord(\'a\') else \'z\'\n            else:\n            # reduce to minimum possible charecter\n                res += chr(ord(char)-k)\n                k-=k\n        return res\n        \n```
['String', 'Greedy', 'Python3']