Simple O(N) TC and SC solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# 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```\nclass Solution {\n    public String getSmallestString(String s, int k) {\n        StringBuilder sb = new StringBuilder();\n        if(k == 0) return s;\n        int i;\n        for(i = 0; i < s.length() && k > 0; i++) {\n            if(s.charAt(i) == \'a\') {\n                sb.append(s.charAt(i));\n                continue;\n            }\n            char c = s.charAt(i);\n            int minDist = Math.min((int) c - \'a\' , \'z\' - (int)c + 1);\n            if(k >= minDist) {\n                k -= minDist;\n                sb.append(\'a\');\n            }\n            else {   \n                sb.append((char)((int) c - k));\n                k -= (int) c - \'a\';\n            }\n            \n        }\n        for(; i < s.length(); i++) {\n             sb.append(s.charAt(i));\n        }\n        return sb.toString();\n    }\n\n    // private Character getCharatcer(Character c, int k) {\n    //     int minDist = Math.min((int) c - \'a\' , \'z\' - (int)c + 1);\n        \n    // }\n}\n```
['Java']