1. class Solution {
    2. private:
    3. set<char> vowels = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};
    4. public:
    5. string reverseVowels(string s) {
    6. int p1 = 0, p2 = s.length() - 1;
    7. while (p1 < p2) {
    8. while (p1 < p2 && vowels.count(s[p1]) == 0) {
    9. ++p1;
    10. }
    11. while (p1 < p2 && vowels.count(s[p2]) == 0) {
    12. --p2;
    13. }
    14. if (p1 < p2)
    15. swap(s[p1], s[p2]);
    16. ++p1;
    17. --p2;
    18. }
    19. return s;
    20. }
    21. };