Longest Substring Of All Vowels in Order LeetCode solution in Java

1
class Solution {
2
public int longestBeautifulSubstring(String word) {
3
int max = 0;
4
for (int i = 1; i < word.length(); i++) {
5
int temp = 1;
6
Set<Character> verify = new HashSet<>();
7
verify.add(word.charAt(i - 1));
8
while (i < word.length() && word.charAt(i) >= word.charAt(i - 1)) {
9
temp++;
10
verify.add(word.charAt(i));
11
i++;
12
}
13
max = verify.size() == 5 ? Math.max(max, temp) : max;
14
}
15

16
return max;
17
}
18
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0