Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- static bool comp(char c){
- c = tolower(c);
- return (c == 'a' || c == 'e' || c == 'o' || c == 'i' || c == 'u');
- }
- string reverseVowels(string s) {
- int l = 0, r = s.size() - 1;
- while(l < r){
- while(l < r && !comp(s[l])) l++;
- while(l < r && !comp(s[r])) r--;
- swap(s[l++], s[r--]);
- }
- return s;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement