Straightforward simple one pass Java solution | O(n)
Intuition\nOur goal is to 1st make each character \'a\', else decrement to whatever is the least possible character.\n\n Describe your first thoughts on how to 
# Intuition\nOur goal is to 1st make each character \'a\', else decrement to whatever is the least possible character.\n\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nWe have 2 conditions to check:\n1. If incrementing characters upto k times can get us \'a\'.\n2. If decrementing characters upto k times can get us \'a\'.\n\nIf <b>1st</b> conditions is satisfied then we can be sure that current character can be replaced by \'a\'. The only condition to check would be if decrementing leads to lesser operations.\n\nIf <b>2nd</b> condition is true, then decrement k by the difference of current character and \'a\'. <br> If none of the conditions is true, just decrement the character by k.\n\nEach iteration, we need to reduce the value of k by appropriate difference.\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        char[] arr = s.toCharArray();\n        \n        for(int i=0; i<s.length() && k > 0; i++) {\n            if(arr[i] == \'a\')\n                continue;\n            int curr = arr[i] - \'a\';\n            \n            boolean canBeA = curr + k >= 26;\n            if(canBeA) {\n                arr[i] = \'a\';\n                int leftDist = Math.min(curr, k);\n                int rightDist = 26 - curr;\n                \n                int minDist = Math.min(leftDist, rightDist);\n                k -= minDist;\n            } else {\n                if(curr <= k) {\n                    arr[i] = \'a\';\n                    k -= curr;\n                } else {\n                    arr[i] = (char)(curr - k + \'a\');\n                    k = 0;\n                }\n            }\n        }\n        \n        return new String(arr);\n    }\n}\n```
['String', 'Java']