C++ Solution
\n\n# Code\n\nclass Solution {\npublic:\n    string smallestString(string s) {\n        string o=s;\n        if(s[0]!=\'a\'){\n            int i=0;\n           
\n\n# Code\n```\nclass Solution {\npublic:\n    string smallestString(string s) {\n        string o=s;\n        if(s[0]!=\'a\'){\n            int i=0;\n            while(i<s.length() && s[i]!=\'a\'){\n                i++;\n            }\n            for(int a=0;a<i;a++){\n                s[a]=s[a]-1;\n            }\n        }\n        else{\n            int i=0;\n            while(i<s.length() && s[i]==\'a\'){\n                i++;\n            }\n            int j=i;\n            while(j<s.length() && s[j]!=\'a\'){\n                j++;\n            }\n            for(int a=i;a<j;a++){\n                s[a]-=1;\n            }\n        }\n        if(s==o){\n            int n=s.length();\n            if(s[n-1]==\'a\'){\n                s[n-1]=\'z\';\n            }\n            else{\n                s[n-1]-=1;\n            }\n        }\n        return s;\n        \n    }\n};\n```
['C++']