Easy Solution using Recursion
IntuitionThe problem requires finding the longest substring that contains all five vowels ('a', 'e', 'i', 'o', 'u') in order. The approach involves checking eac
# Intuition
The problem requires finding the longest substring that contains all five vowels ('a', 'e', 'i', 'o', 'u') in order. The approach involves checking each potential starting point of such a substring and verifying if it meets the criteria.

# Approach
Initialization: Define the sequence of vowels and a helper function check to validate the substring.
Helper Function: The check function recursively verifies if the substring starting at a given index contains all vowels in order.
Main Function:
Traverse the string to find all starting points where the substring could potentially be beautiful (i.e., starting with 'a').
For each starting point, use the check function to determine the length of the valid beautiful substring.
Keep track of the maximum length found.

# Complexity
- Time complexity:
The main loop runs in O(n) time, where n is the length of the input string. The check function also runs in 
O(n) time in the worst case.

- Space complexity:
O(1)

# Code
```cpp []
class Solution {
public:
    string sequence = "aeiou";
    
    int check(string &word, int j, int k) {
        if ((j >= word.size() && k>=5) || k >= 5) return j;
        char c = sequence[k];
        if (word[j] != c) return 0;
        while (j < word.size() && word[j] == c) j++;
        return check(word, j, k + 1);
    }
    
    int longestBeautifulSubstring(string word) {
        int n = word.size(), ans = 0;
        if (n < 5) return 0;
        vector<int>Afreq;
        if(word[0]=='a')Afreq.push_back(0);
        for(int i=1;i<=n-4;i++){
            if(word[i]=='a')
            {
                if(word[i-1]=='a')continue;
                else Afreq.push_back(i);
            }
        }
        
        for (int i = 0; i < Afreq.size(); i++) {
            
            int j = check(word, Afreq[i], 0);
            ans = max(ans, j - Afreq[i]);
            
        }
        return ans;
    }
};


// Aposition

// aeeeiiiioooauuuaeiou
```
['Two Pointers', 'Recursion', 'Sliding Window', 'C++']