Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 710 Bytes

19.md

File metadata and controls

33 lines (23 loc) · 710 Bytes
    bool halvesAreAlike(string s) {
        
         // Convert the string to lowercase
    for (auto &ch : s) {
        ch = std::tolower(ch);
    }
        int vi=0;

        vector<char>v{'a','e','i','o','u'};

        for(int i=0;i<s.size();i++)
            if(find(v.begin(),v.end(),s[i])!=v.end())
                 vi++;

        if(vi%2!=0)
            return false;

        int t=0;
        for(int i=0;i<s.size()/2;i++)
        {
           if(find(v.begin(),v.end(),s[i])!=v.end())
                t++;

        }

        return vi/2==t;
    }