leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1839.cpp (594B)
0 class Solution {
1 public:
2 int longestBeautifulSubstring(const string &word) const {
3 static const char *order = "aeiou";
4 int i = 0, j = 0, cnt = 0;
5 int res = 0;
7 while (i < size(word)) {
8 if (word[i] == order[j]) {
9 while (word[i] == order[j])
10 i++, cnt++;
11 if (++j == 5) res = max(res, cnt);
12 } else {
13 while (i < size(word) && word[i] != 'a')
14 i++;
15 cnt = 0;
16 j = 0;
17 }
18 }
20 return res;
21 }
22 };