The Quest for the Longest Beautiful Substring: A Vowel Odyssey 🎶🔍 (BEATS 100%)
Intuition 🧠💡Alright, let's tackle this problem step by step! Imagine you're on a quest to find the most melodious substring in a string of vowels. The melody mu
# Intuition 🧠💡
Alright, let's tackle this problem step by step! Imagine you're on a quest to find the most melodious substring in a string of vowels. The melody must follow the order 'a', 'e', 'i', 'o', 'u'—like a musical scale going up 🎧. And not just any scale, but one that includes all five vowels in order!

So, our goal is to find the longest substring where the vowels appear in this exact increasing order, and all five must be present. Think of it like finding the longest "aeiou" sequence in a jumbled string of letters.

# Approach 🚀🔍
Here's how we can approach this melodious problem:

****Initialize Trackers:**** We'll keep track of:

**count:** How many distinct vowels in order we've seen so far in the current substring.

**left:** The starting index of our current potential melodious substring.

**ans:** The length of the longest valid substring we've found.

**Slide Through the String: We'll slide a window from the second character to the end:**

If the current character is less than the previous one, it breaks our sequence. Time to reset! 🚨

Set count back to 1 (starting fresh with the current character).

Move left to the current position.

If the current character is greater than the previous one, it's the next vowel in our sequence! 🎉

Increment count.

If it's the same, we just continue (no change to count).

**Check for Full Melody:** Whenever count hits 5, it means we've got all five vowels in order! �

Calculate the length of this substring (right - left + 1).
Update ans if this is the longest we've found.

**Return the Result:** After sliding through the entire string, ans will hold the length of the longest melodious substring. If none, it'll be 0.

# Complexity 📊
**Time Complexity: O(n)** – We're sliding through the string once, so it's linear time. Efficient! ⚡

**Space Complexity: O(1)** – We're using a constant amount of extra space. No extra memory hogging here! 🐜

# Code
```cpp []
class Solution {
public:
    int longestBeautifulSubstring(string word) {
        int count=1,ans=0,left=0;
        for(int right=1;right<word.size();++right){
            if(word[right]<word[right-1]){
                count=1;
                left=right;
            }
            else if(word[right]>word[right-1]){
                count++;
            }
            if(count==5){
                ans=max(ans,right-left+1);
            }

        }
        return ans;
    }
};
```

# Upvote for the Vowel Hunter! 🎯🔥
**Hey fellow coders! 👋**

If you enjoyed this **musical journey through vowels** and found the solution helpful, don’t forget to smash that **upvote button!** ⬆️✨

Your support keeps the **coding symphony alive**—let’s make **beautiful substrings** trend! 🎶💻

# Happy Coding! 🚀😃
['String', 'Sliding Window', 'C++']