Simple python3 solution with comments | 143 ms - faster than 66.67% solutions
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n) for answer\n Add your space complexity here, e.g. O(
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$ for answer\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n``` python3 []\nclass Solution:\n    def smallestString(self, s: str) -> str:\n        s = list(s)\n\n        i = 0\n        n = len(s)\n        # skip first \'a\'\n        while i < n and s[i] == \'a\':\n            i += 1\n        \n        if i == n:\n            # s consist only \'a\', replace last\n            s[-1] = \'z\'\n        else:\n            # replace char, while it is not \'a\'\n            while i < n and s[i] != \'a\':\n                s[i] = chr(ord(s[i]) - 1)\n                i += 1        \n        return \'\'.join(s)\n```
['Greedy', 'Iterator', 'Python3']