C++ slinding window solution very easy
\nclass Solution {\npublic:\n    int longestBeautifulSubstring(string word) {\n        int ans=0;\n        for (int i=0;i<word.size();)\n        {\n            
```\nclass Solution {\npublic:\n    int longestBeautifulSubstring(string word) {\n        int ans=0;\n        for (int i=0;i<word.size();)\n        {\n            int j=i;\n\t\t\t// we have flag variables for each vowel so that we can know that we have got each vowel in order.\n            bool flaga=false,flage=false,flagi=false,flago=false,flagu=false;\n            while (j<word.size()&&word[j]==\'a\')\n            {\n                flaga=true;\n                j++;\n            }\n\t\t\t// if we don\'t get vowel \'a\' hence we can simply cotinue to next position, as there id no use of trying for other vowels\n\t\t\t// this same is happening for each vowel using flag variables\n            if (!flaga){\n                i=j+1;\n                continue;\n            }\n            while (flaga&&j<word.size()&&word[j]==\'e\')\n            {\n                flage=true;\n                j++;\n            }\n            while (flage&&j<word.size()&&word[j]==\'i\')\n            {\n                flagi=true;\n                j++;\n            }\n            while (flagi&&j<word.size()&&word[j]==\'o\')\n            {\n                flago=true;\n                j++;\n            }\n            while (flago&&j<word.size()&&word[j]==\'u\')\n            {\n                flagu=true;\n                j++;\n            }\n\t\t\t// if we got all vowels then update the answer else simply move to further index.\n            if (flaga&&flage&&flagi&&flago&&flagu)\n            {\n                ans=max(ans,j-i);\n            }\n            i=j;\n        }\n        return ans;\n    }\n};\n```\nkindly ask if any doubt there.\n
[]