Short & clean c++ intuitive code using sliding window & unordered_map
\nclass Solution {\npublic:\n    int longestBeautifulSubstring(string word) {\n        unordered_map<char, int> mp;\n        int i = 0, ans = 0; \n        for(i
```\nclass Solution {\npublic:\n    int longestBeautifulSubstring(string word) {\n        unordered_map<char, int> mp;\n        int i = 0, ans = 0; \n        for(int j=0; j<word.length(); j++) {\n            if(mp.empty() && word[j] == \'a\') {\n                i = j;\n                mp[word[j]]++;\n            } else if(!mp.empty()) {\n                if(word[j] < word[j-1]) {\n                    mp.clear();\n                    j--;\n                    continue;\n                }\n                mp[word[j]]++;\n                if(mp.size() == 5)  ans = max(ans, j - i + 1); \n            }\n        }\n        return ans;\n    }\n};\n```
['Two Pointers', 'C', 'Sliding Window']