Leetcode 345 Reverse vowels of a String

Source: Internet
Author: User

Test instructions: The vowel letter in the inverted string.

Use two subscripts to point to the front and back two relative vowel letters, and then swap.

Note: The vowel letter is Aeiouaeiou.

1 classSolution {2  Public:3     BOOLIsvowels (Charc) {4         stringvowels ="Aeiouaeiou";5          for(inti =0; I < vowels.size (); ++i) {6             if(c = = Vowels[i])return true;7         }8         return false;9     }Ten     stringReversevowels (strings) { One         inti =0, j = s.size ()-1; A          while(I <j) { -             if(!isvowels (s[i)) + +i; -             if(!isvowels (S[j]))--J; the             if(Isvowels (s[i]) &&isvowels (S[j])) { - swap (s[i],s[j]); -++i,--J; -             } +         } -         returns; +     } A};

Leetcode 345 Reverse vowels of a String

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.