C++ Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n    - There is some posibility :\n      1. If there is no occurence of \'a\' letter the
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n    - There is some posibility :\n      1. If there is no occurence of \'a\' letter then simply just\n         assign the previous character of each letter.\n      2. If there is one occurence of \'a\' letter then.\n        1. If \'a\' at 0th index then simply just assign the previous\n           character for 1...n.\n        2. if \'a\' other than 0th index then simply just assgin\n           the previous character for 0...ith.\n      3. If there is more than one occurence then simply collect\n         the all occurence of \'a\' letter then traverse that vector\n         and check there difference between consecutive occurence\n         greater than \'1\' or not.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    - Time : O(N);\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    - Space : O(N);\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    string smallestString(string s) {\n        ios_base::sync_with_stdio(false);\n        cin.tie(0);\n        cout.tie(0);\n        int n = s.size();\n        vector<int> aCurr;\n        for (int i = 0; i < n; i++) {\n            if (s[i] == \'a\')\n                aCurr.push_back(i);\n        }\n        if (aCurr.size() == n) {\n            s[n - 1] = \'z\';\n            return s;\n        }\n        if (aCurr.empty()) {\n            for (int i = 0; i < n; i++) {\n                char ch = s[i];\n                ch--;\n                s[i] = ch;\n            }\n        } else {\n            int sz = aCurr.size();\n            if (aCurr[0] != 0) {\n                for (int i = 0; i < aCurr[0]; i++) {\n                    char ch = s[i];\n                    ch--;\n                    s[i] = ch;\n                }\n            } else {\n                bool f = false;\n                for (int i = 1; i < sz; i++) {\n                    if (aCurr[i] - aCurr[i - 1] != 1) {\n                        for (int j = aCurr[i - 1] + 1; j < aCurr[i]; j++) {\n                            char ch = s[j];\n                            ch--;\n                            s[j] = ch;\n                        }\n                        f = true;\n                        break;\n                    }\n                }\n                if (!f) {\n                    for (int i = aCurr[sz - 1] + 1; i < n; i++) {\n                        char ch = s[i];\n                        ch--;\n                        s[i] = ch;\n                    }\n                }\n            }\n        }\n        return s;\n    }\n};\n```
['C++']