Python solution | Lengthy but beginner friendly
\nclass Solution:\n    def longestBeautifulSubstring(self, word: str) -> int:\n        mx=0\n        ans=0\n        res=""\n        endcaseans=""\n        v="ae
```\nclass Solution:\n    def longestBeautifulSubstring(self, word: str) -> int:\n        mx=0\n        ans=0\n        res=""\n        endcaseans=""\n        v="aeiou"\n        for i in range(0,len(word)-1):\n            if word[i]<=word[i+1]:\n                res+=word[i]\n            else:\n                res+=word[i]\n                endcaseans+=res\n                if "".join(sorted(set(res))) == v:\n                    ans=len(res)\n                    if ans>mx:\n                        mx=ans\n                res=""\n        endcase=word[len(endcaseans):]\n        if "".join(sorted(set(endcase))) == v:\n            if len(endcase)>mx:\n                mx=len(endcase)\n        return mx\n```
[]