🔥VERY SIMPLE LOGIC using only vector🔥🔥. Beginner friendly and easy to understand.
\n# Complexity\n- Time complexity:\n O(n) \n\n- Space complexity:\n O(1) \n\n# Code\n\nclass Solution {\npublic:\n    int longestBeautifulSubstring(string word)
\n# Complexity\n- Time complexity:\n $$O(n)$$ \n\n- Space complexity:\n $$O(1)$$ \n\n# Code\n```\nclass Solution {\npublic:\n    int longestBeautifulSubstring(string word) {\n        int i=0,j=0,n=word.size();\n        int mx=0;\n        vector<char>v={\'a\',\'e\',\'i\',\'o\',\'u\'};\n        while(j<n)\n        {\n            if(word[j]==\'a\')\n            {\n                i=j;\n                int k=0;\n                char c=v[k];\n                while(j<n)\n                {\n                    while(j+1<n&&c==word[j+1])\n                    {\n                        j++;\n                    }\n                    if(k==4) mx=max(mx,j-i+1);\n                    k++;\n                    if(k==5)break;\n                    if(j+1<n&&v[k]!=word[j+1])break;  \n                    c=v[k];\n                      j++;\n                }\n            }\n            j++;\n        }\n        return mx;\n    }\n};\n```
['Two Pointers', 'Sliding Window', 'C++']