6 Liner Solution || Very Easy || Python3
Time Complexity:- O(n)\n\nSpace Complexity:- O(n)\n\nExplanation of my code:\n\n=> Initialize an empty string \'res\' to store the result.\n\n=> Iterate through
**Time Complexity:-** *O(n)*\n\n**Space Complexity:-** *O(n)*\n\n**Explanation of my code:**\n\n**=>** *Initialize an empty string \'res\' to store the result.*\n\n**=>** *Iterate through each character in the input string \'s\'.*\n\n**=>** *For each character, calculate the minimum distance to reach \'a\' or \'z\' from the current character.*\n\n**=>** *Append \'a\' to the result string if the remaining steps are greater than or equal to the minimum distance, else decrement the character value by the remaining steps.*\n\n**=>** *Update the remaining steps based on the minimum distance taken.*\n\n**=>** *Return the resulting smallest string.*\n\n**CODE:-**\n```\nclass Solution:\n    def getSmallestString(self, s: str, k: int) -> str:\n        res = ""  # Initialize an empty string to store the result\n        for char in s:\n            # Calculate the minimum distance to reach \'a\' or \'z\' from the current character\n            min_d = min(ord(char) - ord(\'a\'), ord(\'z\') - ord(char) + 1)\n            # Append \'a\' if remaining steps are greater than or equal to the minimum distance, else decrement the character value\n            res += \'a\' if k >= min_d else chr(ord(char) - k)\n            # Update remaining steps based on the minimum distance taken\n            k -= min_d if k >= min_d else k\n        return res  # Return the smallest string\n```\n\n**If this is helpful please upvote it**
['String', 'Python3']