lexicographically-smallest-string-after-operations-with-constraint
Intuition\nIt is brute force approach to check\nif it is possible to get \'a\' from either left or right side\nChoose the min side\n# Approach\nAlways try to ge
# Intuition\nIt is brute force approach to check\nif it is possible to get \'a\' from either left or right side\nChoose the min side\n# Approach\nAlways try to get \'a\' because we need lexicographically-smallest-string\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n# Code\n```\nclass Solution:\n    def getSmallestString(self, s: str, k: int) -> str:\n        s = list(s)\n        n = len(s)\n        for i in range(n):\n            \n            asc = ord(s[i]) - 97\n            m1 = 1<<31\n            m2 = 1<<31\n            if(asc - k <= 0):\n                m1 = asc\n            if(asc + k >= 26):\n                m2 = 26-asc\n            if(m1 == 1<<31 and m2 == 1<<31):\n                s[i] = chr(asc - k + 97)\n                break\n            if(m1 < m2):\n                k -= asc\n            else:\n                k -= (26-asc)\n            s[i] = \'a\'\n            \n                \n            #print(k)\n        return "".join(s)\n\n        \n\n        \n```
['Python3']