Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public:
- bool isVowel(char c){
- if(c=='u'||c=='U'){
- return true;
- }else if(c=='o'||c=='O'){
- return true;
- }else if(c=='a'||c=='A'){
- return true;
- }else if(c=='e'||c=='E'){
- return true;
- }else if(c=='i'||c=='I'){
- return true;
- }else{
- return false;
- }
- }
- string reverseVowels(string s) {
- vector<char> vowel;
- for(char c:s){
- if(isVowel(c)){
- vowel.push_back(c);
- }
- }
- reverse(vowel.begin(),vowel.end());
- string ans;
- int ind=0;
- for(char c:s){
- if(isVowel(c)){
- ans=ans+vowel[ind];
- ind++;
- }else{
- ans=ans+c;
- }
- }
- return ans;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement