Skip to content

Commit d465749

Browse files
committed
Time: 87 ms (8.63%) | Memory: 13.8 MB (39.29%) - LeetSync
1 parent 4e13841 commit d465749

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
class Solution {
2+
public:
3+
string sortVowels(string s) {
4+
vector<char> vowels;
5+
for (char c : s) {
6+
if (string("aeiouAEIOU").find(c) != string::npos) {
7+
vowels.push_back(c);
8+
}
9+
}
10+
sort(vowels.begin(), vowels.end(), greater<char>());
11+
string result;
12+
for (char c : s) {
13+
if (string("aeiouAEIOU").find(c) != string::npos) {
14+
result += vowels.back();
15+
vowels.pop_back();
16+
} else {
17+
result += c;
18+
}
19+
}
20+
return result;
21+
}
22+
};

0 commit comments

Comments
 (0)