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)


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