C++ || Greedy solution
\n\n\n# Approach\n  think greedily \n        if a early dont bother otherwise bother and bother till next a\n        if all a\'s update only last\n\n\n# Complex
\n\n\n# Approach\n  think greedily \n        if a early dont bother otherwise bother and bother till next a\n        if all a\'s update only last\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n    string smallestString(string s) {\n        int i = 0,n=s.size();\n        while(i<n && s[i] == \'a\') i++;\n        if(i == n) s[n-1] = \'z\';\n        while(i<n && s[i]!=\'a\'){\n            s[i] = \'a\' + (s[i]-\'a\')-1;\n            i++;\n        }\n        return s;\n    }\n};\n```
['Greedy', 'C++']