Game of Thrones - I

  • + 2 comments

    Thanks. This worked nicely with c++ bitsets and use of flip function.

    string s;
    cin>>s;
    int flag = 0;
    
    bitset<26> bs(std::string("00000000000000000000000000"));
    
    for(int i = 0 ; i < s.size(); i++)
    {
        bs.flip(s[i]-'a');     
    }
    if((s.size() % 2 !=0) 
        && (bs.count() == 1))
    {
        flag = 1; 
    }
    else if ((s.size() %2 == 0)
        && (bs.count() == 0))
    {
        flag = 1;     
    }
    if(flag==0)
        cout<<"NO";
    else
        cout<<"YES";
    return 0;