package com.fishercoder.solutions;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class _1456 {
    public static class Solution1 {
        public int maxVowels(String s, int k) {
            Map<Character, Integer> vowels = new HashMap<>();
            Set<Character> set = new HashSet<>();
            set.add('a');
            set.add('e');
            set.add('i');
            set.add('o');
            set.add('u');
            int left = 0;
            for (; left < k; left++) {
                if (set.contains(s.charAt(left))) {
                    vowels.put(s.charAt(left), vowels.getOrDefault(s.charAt(left), 0) + 1);
                }
            }
            int max = 0;
            for (char c : vowels.keySet()) {
                max += vowels.get(c);
            }
            int right = left;
            left = 0;
            for (; right < s.length(); right++, left++) {
                char leftChar = s.charAt(left);
                if (set.contains(leftChar) && vowels.containsKey(leftChar) && vowels.get(leftChar) > 0) {
                    vowels.put(leftChar, vowels.get(leftChar) - 1);
                }
                char rightChar = s.charAt(right);
                if (set.contains(rightChar)) {
                    vowels.put(rightChar, vowels.getOrDefault(rightChar, 0) + 1);
                }
                int thisMax = 0;
                for (char c : vowels.keySet()) {
                    thisMax += vowels.get(c);
                }
                max = Math.max(max, thisMax);
            }
            return max;
        }
    }
}

@@ -29,16 +29,41 @@
 tions;%0A%0A
+import java.util.Arrays;%0A
 import j
@@ -369,139 +369,47 @@
 t%3C%3E(
-);%0A            set.add('a');%0A            set.add('e');%0A            set.add('i');%0A            set.add('o');%0A            set.add(
+Arrays.asList('a', 'e', 'i', 'o', 
 'u')
+)
 ;%0A  

refactor 1456