Skip to content

Commit 928d6a1

Browse files
committed
Update reverse-vowels-of-a-string.cpp
1 parent 5e7363c commit 928d6a1

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

C++/reverse-vowels-of-a-string.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ class Solution {
55
public:
66
string reverseVowels(string s) {
77
for (int i = 0, j = s.length() - 1; i < j;) {
8-
if (is_vowel(tolower(s[i])) &&
9-
is_vowel(tolower(s[j]))) {
10-
swap(s[i++], s[j--]);
11-
} else if (!is_vowel(tolower(s[i]))) {
8+
if (!is_vowel(tolower(s[i]))) {
129
++i;
13-
} else {
10+
} else if (!is_vowel(tolower(s[j]))) {
1411
--j;
12+
} else {
13+
swap(s[i++], s[j--]);
1514
}
1615
}
1716
return s;

0 commit comments

Comments
 (0)