leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1704.cpp (354B)


      1 class Solution {
      2     bool is_vowel(char c) { return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'; }
      3 
      4   public:
      5     bool halvesAreAlike(string s) {
      6         int i = 0, j = s.size() / 2, count = 0;
      7         while (j < s.size())
      8             count += is_vowel(tolower(s[i++])) - is_vowel(tolower(s[j++]));
      9         ;
     10         return !count;
     11     }
     12 };