[Java/C++/Python] Straight Forward Solution
Explanation\n1. a in prefix is good, skip all a in the beginning.\n2. If all characters are a, change the last char to z.\n3. From the first char not a, decrese
# **Explanation**\n1. `a` in prefix is good, skip all `a` in the beginning.\n2. If all characters are `a`, change the last char to `z`.\n3. From the first char not `a`, decrese them, until next `a`.\n\n# **Complexity**\nTime `O(n)`\nSpace `O(n)`\n<br>\n\n**Java**\n```java\n    public String smallestString(String s) {\n        int i = 0, n = s.length();\n        char[] A = s.toCharArray();\n        while (i < n && A[i] == \'a\')\n            i++;\n        if (i == n)\n            A[n - 1] = \'z\';\n        while (i < n && A[i] != \'a\')\n            --A[i++];\n        return String.valueOf(A);\n    }\n```\n\n**C++**\n```cpp\n    string smallestString(string s) {\n        int i = 0, n = s.size();\n        while (i < n && s[i] == \'a\')\n            i++;\n        if (i == n)\n            s[n - 1] = \'z\';\n        while (i < n && s[i] != \'a\')\n            --s[i++];\n        return s;\n    }\n```\n\n**Python**\n```py\n    def smallestString(self, s):\n        i = 0\n        n = len(s)\n        s = list(s)\n        while i < n and s[i] == \'a\':\n            i += 1\n        if i == n:\n            s[-1] = \'z\'\n        while i < n and s[i] != \'a\':\n            s[i] = chr(ord(s[i]) - 1)\n            i += 1\n        return \'\'.join(s)\n```\n
['C', 'Python', 'Java']