Easy understanding | Brute Force | No extra space | Simple c++
C++ solution:\n\nclass Solution {\npublic:\n    \n    int longestBeautifulSubstring(string s) {\n        int n=s.size();\n        int ans=0;\n        for(int i=
**C++ solution:**\n```\nclass Solution {\npublic:\n    \n    int longestBeautifulSubstring(string s) {\n        int n=s.size();\n        int ans=0;\n        for(int i=0;i<n;)\n        {\n            if(s[i]==\'a\')\n            {\n                int c=1;\n                int count=0;\n                while(i<n&&s[i]==\'a\')\n                {\n                    count++;\n                    i++;\n                }\n                //cout<<"a "<<count<<endl;\n                if(i<n&&s[i]==\'e\')\n                {\n                    c++;\n                    while(i<n&&s[i]==\'e\')\n                    {\n                        count++;\n                        i++;\n                    }\n                   // cout<<"e "<<count<<endl;\n                    if(i<n&&s[i]==\'i\')\n                    {\n                        c++;\n                        //count++;\n                        while(i<n&&s[i]==\'i\')\n                        {\n                            count++;\n                            i++;\n                        }\n                       // cout<<"i "<<count<<endl;\n                        if(i<n&&s[i]==\'o\')\n                        {\n                            c++;\n                            //count++;\n                            while(i<n&&s[i]==\'o\')\n                            {\n                                count++;i++;\n                            }\n                            //cout<<"o "<<count<<endl;\n                            if(i<n&&s[i]==\'u\')\n                            {\n                                c++;\n                                c=5;\n                                //count++;\n                                while(i<n&&s[i]==\'u\')\n                                {\n                                    count++;\n                                    i++;\n                                }\n\n                            }\n                            //cout<<"u "<<count<<endl;\n\n                        }\n                    }\n                }\n                \n                if(c==5)\n                {\n                    ans=max(ans,count);\n                }\n                \n            }\n            else\n                    i++;\n        }\n        return ans;\n    }\n};\n```
['C']