Python3 👍||⚡98/100 faster beats 🔥|| simple explain ||
\n\n\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) 
![image.png](https://assets.leetcode.com/users/images/87e1aa4c-6441-4d67-b2fb-846fc3897b29_1687376176.900977.png)\n\n\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    def smallestString(self, s: str) -> str:\n        \n        if len(check:=set(s))==1 and check != {\'a\'}: \n            return chr(ord(s[0])-1)*(len(s))              # zzzz > yyyy , aaaa -X-> zzzz\n        contiguous,change,ct1,ct2 = True,False,0,0\n\n        for i in s:                                       # deal with begin string = \'aaaa....\', speed up the traversal speed.\n            if i == \'a\':ct1+=1                                                  \n            else:break\n        ans=\'\' + \'a\' * ct1\n        s = s[ct1:]\n     \n        for cha in s:\n            ct2+=1\n            if cha != \'a\':\n                ans+=chr(ord(cha)-1)\n                change=True                               # record operation at least once.\n                continue\n            else:\n                ans+=cha                                  # because \'a\' can\'t converted to \'z\'\n                if change:                                # once the change has been made, you can stop when you encounter \'a\'\n                    contiguous = False\n            if not contiguous:                            # then break , add the remaining string to the end of the ans.\n                break\n        return ans+s[ct2:] if change else ans[:-1]+\'z\'    # check if it consists entirely of the letter "a."  \'aaaa\' > \'aaaz\'\n```\n\nMy English may not be very good, but I hope I can still assist you. :>\n\n\n\n\n
['String', 'Python3']