Super simple C++ Solution; easy to follow. O(N) time and O(1) space.
Intuition\n Describe your first thoughts on how to solve this problem. \nWe have two cases: string is all \'a\' or is not. We want to minimize the a\'s we flip 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe have two cases: string is all \'a\' or is not. We want to minimize the a\'s we flip to z, flipping 1 if all \'a\'s, otherwise never.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nIf string is all \'a\'s, flip the last to z and return. Otherwise, find the first non-a index. Starting from that, highten the char order until you reach the next a or end of string. Return string.\n# Complexity\n- Time complexity: $O(N)$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $O(1)$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    string smallestString(string s) {\n        int i = 0;\n        while (i < s.size() && s[i] == \'a\') ++i;\n        if (i == s.size()) return s.substr(0, i - 1) + "z";\n        \n        int start = i;\n        while (i < s.size() && s[i] != \'a\') {\n            s[i] = s[i] - 1;\n            ++i;\n        }\n\n        return s;\n    }\n};\n```
['C++']