Simple & Easy C++ Solution | ✅ Beginner Friendly
Intuition\nSince we need to find lexicographically smallest, we need to minimise the left part of our string. If it already contains \'a\' i.e. smallest letter 
# Intuition\nSince we need to find lexicographically smallest, we need to minimise the **left** part of our string. If it already contains **\'a\'** i.e. smallest letter at start; We need to traverse further to minimize it.\nTraverse the string and try to perform the operation.\nIf no operation has been performed, then it only consists of letter \'a\'. Else required operation has already been performed. \n\n# Approach\nTraverse the string to perform the required operation. Store its state with a bool value. If no operation performed, then just change last character to \'z\'.\n\nCase:- "aaaa" -> "aaaz"\n\n# Complexity\n- Time complexity: $$O(n)$$ \n\n- Space complexity: $$O(1)$$ \n\n# Code\n```\nclass Solution {\npublic:\n    string smallestString(string s) {\n        int n = s.size();bool flag = false;\n        \n\n        for(int i=0; i<n; i++){\n            //If character \'a\' is found and operation has been performed, break the loop\n            //Else continue\n            if(s[i] == \'a\'){\n                if(flag) break;\n            }\n\n            //If character other than \'a\' just decrease it.\n            else{\n                s[i] = s[i]-1;\n                flag = true;\n            }\n        }\n\n        if(!flag) s[n-1] =\'z\';         \n        return s;        \n    }\n};\n```
['String', 'C++']