[C++] Greedy, O(N) Runtime
If all the characters are not a in string s.\n    - Find the first character which is not a.\n    - Operate on the substring from first character which is not a
- If all the characters are not **a** in string `s`.\n    - Find the first character which is not **a**.\n    - Operate on the substring from first character which is not **a** until the next **a** *(or end of string)*.\n- If all the characters are **a** in string `s`.\n    - Simply replace the last character with **z**.\n\n```\nclass Solution {\npublic:\n    string smallestString(string s) {\n        int i = 0;\n        while (i < s.size()) {\n            if (s[i] > \'a\') {\n                break;\n            }\n            i++;\n        }\n        if (i == s.size()) {\n            s[s.size() - 1] = \'z\';\n            return s;\n        }\n        while (i < s.size()) {\n            if (s[i] != \'a\') {\n                s[i] -= 1;\n                i++;\n            } else {\n                break;\n            }\n        }\n        return s;\n    }\n};\n```
['String', 'Greedy', 'C', 'C++']