package leetcode;

/**
 * https://leetcode.com/problems/longest-substring-of-all-vowels-in-order/
 */
public class Problem1839 {
    public int longestBeautifulSubstring(String word) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1839 prob = new Problem1839();
        System.out.println(prob.longestBeautifulSubstring("aeiaaioaaaaeiiiiouuuooaauuaeiu")); // 13
        System.out.println(prob.longestBeautifulSubstring("aeeeiiiioooauuuaeiou")); // 5
        System.out.println(prob.longestBeautifulSubstring("a")); // 0
    }
}

@@ -190,390 +190,978 @@
     
-// TODO%0A        return 0
+int answer = 0;%0A        int count = 1
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1839 prob = new Problem1839();%0A        System.out.println(prob.longestBeautifulSubstring(%22aeiaaioaaaaeiiiiouuuooaauuaeiu%22)); // 13%0A        System.out.println(prob.longestBeautifulSubstring(%22aeeeiiiioooauuuaeiou%22)); // 5%0A        System.out.println(prob.longestBeautifulSubstring(%22a%22)); // 0
+boolean%5B%5D vowels = new boolean%5B5%5D;%0A        vowels%5BtoIndex(word.charAt(0))%5D = true;%0A        for (int i = 0; i %3C word.length() - 1; i++) %7B%0A            if (word.charAt(i) %3C= word.charAt(i + 1)) %7B%0A                count++;%0A            %7D else %7B%0A                count = 1;%0A                vowels = new boolean%5B5%5D;%0A            %7D%0A            vowels%5BtoIndex(word.charAt(i + 1))%5D = true;%0A            boolean allVowels = true;%0A            for (boolean vowel : vowels) %7B%0A                allVowels &= vowel;%0A            %7D%0A            if (allVowels) %7B%0A                answer = Math.max(answer, count);%0A            %7D%0A        %7D%0A        return answer;%0A    %7D%0A%0A    private static int toIndex(char c) %7B%0A        if (c == 'a') %7B%0A            return 0;%0A        %7D%0A        if (c == 'e') %7B%0A            return 1;%0A        %7D%0A        if (c == 'i') %7B%0A            return 2;%0A        %7D%0A        if (c == 'o') %7B%0A            return 3;%0A        %7D%0A        return 4;
 %0A   

Solve problem 1839