Easy to understand Explaination
\n\nclass Solution {\n    public int longestBeautifulSubstring(String word) {\n        char[] arr = word.toCharArray();\n        int maxLength = 0;\n        \n 
```\n\nclass Solution {\n    public int longestBeautifulSubstring(String word) {\n        char[] arr = word.toCharArray();\n        int maxLength = 0;\n        \n        for(int i = 1 ; i < word.length() ; i++){\n            if(arr[i-1] == \'a\'){ //we know that our valid window will only start from a , throgh this line we can increase the performance because it is not checking each and every substring.\n                int currentLength = 1; //because it  includes that char which is present at i-1th index.i.e \'a\' = 1(length)\n                int uniqueCharacter = 1; //the char present at i-1th index would be first unique character for that substring/window i.e \'a\'\n                while( i < word.length() && arr[i-1] <= arr[i]){ //check whether arr[i-1]<= arr[i] to maintain the vowels order.\n                    uniqueCharacter += arr[i-1] < arr[i] ? 1 : 0; //unique character will only increase when arr[i-1] is strictly smaller than arr[i].\n                    currentLength += 1; // currentLength would be increase because the window can have multiple same characters but in a maintained order.\n                    i++; //increase the window size since we need to find out the longest as our ans.\n                    \n                }\n                \n                if(uniqueCharacter == 5){ //that means in your current window you have all vowels in an order ( a , e, i , o , u)\n                    maxLength = Math.max(maxLength , currentLength);\n                     \n                }\n           }\n        }\n        \n        return maxLength; \n        \n    }\n}\n```\n\n**If you found this useful then please upvote <3**
[]