package leetcode;

/**
 * https://leetcode.com/problems/maximum-number-of-vowels-in-a-substring-of-given-length/
 */
public class Problem1456 {
    public int maxVowels(String s, int k) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem1456 prob = new Problem1456();
        System.out.println(prob.maxVowels("abciiidef", 3)); // 3
        System.out.println(prob.maxVowels("aeiou", 2)); // 2
        System.out.println(prob.maxVowels("leetcode", 3)); // 2
        System.out.println(prob.maxVowels("rhythms", 3)); // 4
        System.out.println(prob.maxVowels("tryhard", 4)); // 4
    }
}

@@ -193,82 +193,197 @@
     
-// TODO%0A        return 0;%0A    %7D%0A%0A    public static void main(String%5B%5D args
+int max = 0;%0A        for (int i = 0; i %3C k; i++) %7B%0A            if (s.charAt(i) == 'a' %7C%7C s.charAt(i) == 'e' %7C%7C s.charAt(i) == 'i' %7C%7C%0A                s.charAt(i) == 'o' %7C%7C s.charAt(i) == 'u'
 ) %7B%0A
@@ -394,361 +394,479 @@
     
+  
-Problem1456 prob = new Problem1456();%0A        System.out.println(prob.maxVowels(%22abciiidef%22, 3)); // 3%0A        System.out.println(prob.maxVowels(%22aeiou%22, 2)); // 2%0A        System.out.println(prob.maxVowels(%22leetcode%22, 3)); // 2%0A        System.out.println(prob.maxVowels(%22rhythms%22, 3)); // 4%0A        System.out.println(prob.maxVowels(%22tryhard%22, 4)); // 4
+      max++;%0A            %7D%0A        %7D%0A        int answer = max;%0A        for (int i = k; i %3C s.length(); i++) %7B%0A            if (isVowel(s.charAt(i))) %7B%0A                max++;%0A            %7D%0A            if (isVowel(s.charAt(i - k))) %7B%0A                max--;%0A            %7D%0A            answer = Math.max(answer, max);%0A        %7D%0A        return answer;%0A    %7D%0A%0A    private static boolean isVowel(char c) %7B%0A        return c == 'a' %7C%7C c == 'e' %7C%7C c == 'i' %7C%7C c == 'o' %7C%7C c == 'u';
 %0A   

Solve problem 1456