Easy C++ Single Pass Approach
We are going to store last vowel occured,number of unique vowels,the global max for string length, and local max for string length.\nAt each iteration we will c
We are going to store **last vowel occured,number of unique vowels,the global max for string length, and local max for string length.**\nAt each iteration we will check for three cases:\n1. Is incoming vowel equal to the previous vowel stored\n\t* We just increment the local max length of the string. \n\n2. if incoming vowel is greater than the previous vowel stored\n\t* We increment the local max length ,and update the previous vowel index as well as unique vowel index\n\n3. is incoming vowel if smaller than the previous vowel stored\n\t*  We reset the local max length,unique vowels index as well as previous vowel index.\n\nAt the end of each iteration we check if number of unique vowels encountered is 5 ,we then update the global max length of the string. \t\n\n```\nclass Solution {\npublic:\n    int longestBeautifulSubstring(string word) {\n\n        int lastVow=-1;\n        int uniqueVows=0;\n        int maxString=0;\n        int currLen=0;\n        int n=word.size();\n        \n        for(int i=0;i<n;i++)\n        {\n            if(lastVow==word[i])        //if same vowels occur\n            {\n                currLen++;\n            }\n            else if(lastVow<word[i])    //check if new Vowel is greater than lastone\n            {\n                lastVow=word[i];\n                uniqueVows++;\n                currLen++;\n            }\n            else                    //if smaller vowel occur\n            {\n                currLen=1;\n                uniqueVows=1;\n                lastVow=word[i];\n            }\n            if(uniqueVows==5)       //if all vowels occur once\n                maxString=max(maxString,currLen);\n        }\n        return maxString;\n        \n        \n    }\n};\n```
['C']