Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- knakul853
- **/
- class Solution {
- public:
- string reverseVowels(string s) {
- int i=0;
- int j = (int)s.size()-1;
- string vowels="aeiouAEIOU";
- while(i <j )
- {
- while(i < j && vowels.find(s[i]) == string::npos){
- i++;
- }
- while(i < j && vowels.find(s[j])== string::npos) j--;
- if(i < j )
- {
- swap(s[i], s[j]);
- }
- i++;j--;
- }
- return s;
- }
- };
Add Comment
Please, Sign In to add comment