JS - Simple O(n) Solution
Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n\n/**\n * @param {string} s\n * @param {number} k\n * @return {string}\n */\nvar getS
# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(1)\n\n# Code\n```\n/**\n * @param {string} s\n * @param {number} k\n * @return {string}\n */\nvar getSmallestString = function (s, k) {\n    const str = s.split("");\n\n    for (let i = 0; i < str.length && k >= 0; i++) {\n        const distanceFromA = str[i].charCodeAt(0) - \'a\'.charCodeAt(0);\n        const cyclicDistanceFromA = Math.min(distanceFromA, 26 - distanceFromA);\n        \n        // Try to set the current character to \'a\' if possible\n        if (cyclicDistanceFromA <= k) {\n            str[i] = \'a\';\n            k -= cyclicDistanceFromA;\n        // Otherwise, move it as close to \'a\' as possible\n        } else {\n            str[i] = String.fromCharCode(str[i].charCodeAt(0) - k);\n            k = 0;\n        }\n    }\n\n    return str.join("");\n};\n```
['Greedy', 'JavaScript']