✅C++ Accepted | Greedy | O(26*n)⛳
\n# Code\n\nclass Solution {\npublic:\n    string getSmallestString(string s, int k) {\n        string res = "";\n        \n        map<char,pair<int,int>> mp;\
\n# Code\n```\nclass Solution {\npublic:\n    string getSmallestString(string s, int k) {\n        string res = "";\n        \n        map<char,pair<int,int>> mp;\n        for(int i=1;i<=26;i++){\n            mp[\'a\'+i-1] = {i,i+26};\n        }\n        \n        for(int i=0;i<s.size();i++){\n            for(char c = \'a\'; c<=\'z\' ; c++){\n                pair<int,int> p1 = mp[c];\n                pair<int,int> p2 = mp[s[i]];\n                int mini = 1e9;\n                mini = min(mini,abs(p1.first-p2.first));\n                mini = min(mini,abs(p1.second-p2.first));\n                mini = min(mini,abs(p1.first-p2.second));\n                mini = min(mini,abs(p1.second-p2.second));\n                if( mini <= k){\n                    res += c;\n                    k -= mini;\n                    break;\n                }\n            }    \n        }\n        return res;\n    }\n};\n```
['C++']