blob: aa9a0391c9fb0b47a086fb36af03f5b7967325f8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include "leetcode.h"
class Solution {
public:
string reverseVowels(string s) {
int i = 0, j = s.size() - 1;
while (i < j) {
i = s.find_first_of("aeiouAEIOU", i);
j = s.find_last_of("aeiouAEIOU", j);
if (i < j)
swap(s[i++], s[j--]);
}
return s;
}
};
int main() {
Solution obj;
cout << obj.reverseVowels("hello");
}
|