Longest Substring Of All Vowels in Order LeetCode solution in Java
1class Solution {2public int longestBeautifulSubstring(String word) {3int max = 0;4for (int i = 1; i < word.length(); i++) {5int temp = 1;6Set<Character> verify = new HashSet<>();7verify.add(word.charAt(i - 1));8while (i < word.length() && word.charAt(i) >= word.charAt(i - 1)) {9temp++;10verify.add(word.charAt(i));11i++;12}13max = verify.size() == 5 ? Math.max(max, temp) : max;14}1516return max;17}18}