C++ | Easy to understand | Time Complexity - O(N) | Space Complexity - O(1)
\nclass Solution {\npublic:\n    int longestBeautifulSubstring(string word) {\n        int n  = word.length();\n        \n        int i = 0;\n        int ans = 
```\nclass Solution {\npublic:\n    int longestBeautifulSubstring(string word) {\n        int n  = word.length();\n        \n        int i = 0;\n        int ans = 0;\n        \n        while(i<n){\n            int ac = 0;\n            int ec = 0;\n            int ic = 0;\n            int oc = 0;\n            int uc = 0;\n            \n            while(i<n && word[i]==\'a\'){\n                ac++;\n                i++;\n            }\n            \n            while(i<n && word[i]==\'e\'){\n                ec++;\n                i++;\n            }\n            \n            while(i<n && word[i]==\'i\'){\n                ic++;\n                i++;\n            }\n            \n            while(i<n && word[i]==\'o\'){\n                oc++;\n                i++;\n            }\n            \n            while(i<n && word[i]==\'u\'){\n                uc++;\n                i++;\n            }\n            \n            if(ac>0 && ec>0 && ic>0 && oc>0 && uc>0){\n                ans = max(ans, ac+ec+ic+oc+uc);\n            }\n        }\n        \n        return ans;\n    }\n};\n```
[]