C++ easy solution using hashmap.
Intuition\nWe would have 2 kinds of strings:-one that contain the character \'a\' and the others with no occurence of \'a\'. The former should be solved as the 
# Intuition\nWe would have 2 kinds of strings:-one that contain the character \'a\' and the others with no occurence of \'a\'. The former should be solved as the latter is simply decrement of each character of the substring. \n\n# Approach\nJust keep storing the frequency of letter \'a\' in a hashmap.In a single character string, we are only left with the alternative to decrement the character and return the answer, but for other cases the second non-continuous occurence of \'a\' is where we stop decrementing our answer.\n\nFor instance if s= "aabdfvfvaavdj" our starting index(considering 0-based indexing) for decrement is 2 and ending index is 7 as starting from index 8 \'a\' appears again. Thus our answer to the above  would be "aaaceueuaavdj".\nFor strings having no occurence of \'a\' in them we would decrement all characters of the string.\n\n# Complexity\n- Time complexity:\nO(N)\n\n- Space complexity:\nO(N)\n\n# Code\n```\nclass Solution {\npublic:\n    string smallestString(string s) {\n       map<char,int> mp,mp1;string ans = "";\n        int start= 0 ,end = 0;\n        if(s[0] == \'a\'){\n            for(int i = 0; i < s.size(); i++)\n                mp1[s[i]]++;\n            if(mp1.size() == 1){\n              for(int i = 0; i < s.size()-1; i++)\n                  ans+=\'a\';\n                  ans+=\'z\';\n                return ans;\n            }\n            else goto end;\n        }\n        end: for(int i = 0; i < s.size(); i++){\n            mp[s[i]]++;\n            if(s[i] == \'a\'){\n            if(mp[\'a\'] >= 1 && i != 0 && mp.size() > 1){\n                for(int j = i; j < s.size(); j++)\n                    ans+=s[j];\n                break;\n            }\n                else ans+=s[i];\n            }\n            else if(s[i] != \'a\'){\n                ans+=(--s[i]);\n            }\n        }\n        return ans;\n    }\n};\n```\nPlease upvote if you liked the solution.
['String', 'Ordered Map', 'C++']