Java/Python Clean Solution
Complexity\n- Time complexity:O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(n)\n Add your space complexity here, e.g. O(n) \n\n# Code
# Complexity\n- Time complexity:$$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n**Java**\n```\nclass Solution {\n    \n    private int helper(char ch){\n        return Math.min(ch-\'a\', 26-(ch-\'a\'));\n    }\n    \n    public String getSmallestString(String s, int k) {\n        char[] ch = s.toCharArray();\n        \n        for(int i=0; i<ch.length; i++){\n            int curr = helper(ch[i]);\n            \n            if(k >= curr){\n                k-=curr;\n                ch[i] = \'a\';\n            } else{\n                if(k>0){\n                    if(ch[i]-k >= \'a\'){\n                        ch[i] = (char)(ch[i]-k);\n                    } else{\n                        ch[i] = (char)(\'z\'-(k-1));\n                    }\n                    k=0;\n                }\n                break;\n            }\n        }\n        return new String(ch);\n    }\n}\n```\n**Python**\n```\nclass Solution:\n    def getSmallestString(self, s: str, k: int) -> str:\n        t = list(s)\n        def dist_to_a(c):\n            return min(ord(c)-ord(\'a\'), 26-(ord(c)-ord(\'a\')))\n        \n        \n        for i in range(len(t)):\n            curr_dist = dist_to_a(t[i])\n            \n            if k>= curr_dist:\n                k -= curr_dist\n                t[i] = \'a\'\n            else:\n                if k>0:\n                    if ord(t[i])-k>=ord(\'a\'):\n                        t[i] = chr(ord(t[i])-k)\n                    else:\n                        t[i] = chr(ord(\'z\')-(k-1))\n                    k=0\n                break\n        return \'\'.join(t)\n```
['Array', 'String', 'String Matching', 'Java', 'Python3']