Easy C++ Solution O(n) Time and O(1) space
We know a<e<i<o<u . So, here we just need to find the length of longest non-decreasing substring with 5 different characters.\n\nclass Solution {\npublic:\n    
We know a<e<i<o<u . So, here we just need to find the length of longest non-decreasing substring with 5 different characters.\n```\nclass Solution {\npublic:\n    int longestBeautifulSubstring(string word) {\n        int j=0;\n        int res=0;\n        unordered_map<char,int> mp;\n        for(int i=0;i<word.size();i++)\n        {\n            if(i>0 && word[i-1]>word[i])\n            {\n                mp.clear();\n                j=i;\n            }\n            mp[word[i]]++;\n            if(mp.size()==5)\n                res=max(res,i-j+1);\n        }\n        return res;\n    }\n};\n```
[]