You are viewing a single comment's thread. Return to all 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;
Seems like cookies are disabled on this browser, please enable them to open this website
Game of Thrones - I
You are viewing a single comment's thread. Return to all comments →
Thanks. This worked nicely with c++ bitsets and use of flip function.