Skip to content

Commit 4a35b50

Browse files
authored
Update count-vowel-substrings-of-a-string.cpp
1 parent 5198294 commit 4a35b50

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

C++/count-vowel-substrings-of-a-string.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ class Solution {
2222
}
2323
++cnt[word[i]];
2424
for (; size(cnt) > k - 1; ++right) {
25-
--cnt[word[right]];
26-
if (!cnt[word[right]]) {
25+
if (!--cnt[word[right]]) {
2726
cnt.erase(word[right]);
2827
}
2928
}
@@ -56,11 +55,10 @@ class Solution2 {
5655
continue;
5756
}
5857
++cnt[word[right]];
59-
while (size(cnt) > k) {
58+
for (; size(cnt) > k; ++left) {
6059
if (!--cnt[word[left]]) {
6160
cnt.erase(word[left]);
6261
}
63-
++left;
6462
}
6563
result += right - left + 1;
6664
}

0 commit comments

Comments
 (0)