My Contest Solution
\n# Code\n\nclass Solution {\npublic:\n    \n    int dist(char a, char b){\n        int may1 = abs(b-a);\n        int may2 = 26 - may1;\n        return min(may1
\n# Code\n```\nclass Solution {\npublic:\n    \n    int dist(char a, char b){\n        int may1 = abs(b-a);\n        int may2 = 26 - may1;\n        return min(may1, may2);\n    }\n    \n    \n    string getSmallestString(string s, int k) {\n        \n        for(char &c : s){\n            int d = dist(c, \'a\');\n            if(d <= k){\n                c = \'a\';\n                k -= d;\n            }else{\n                for(char i = \'a\'; i <= \'z\'; i++){\n                    if(dist(c, i) <= k){\n                        k -= dist(c, i);\n                        c = i;\n                        return s;\n                    }\n                }\n            }\n        }\n        \n        return s;\n    }\n};\n```
['C++']