You are viewing a single comment's thread. Return to all comments →
string happyLadybugs(string b) { unordered_map<char, int> count; int num=0; for(char a: b) { count[a]++; } for(auto a: count ) { if(a.first>='A' && a.first<='Z') num+=a.second; if(a.second==1 && a.first!='_'){ return "NO"; } } if(num==b.size()) { int flag=0; for(int i=1; i<b.size()-1; i++) { if(b[i-1]==b[i] || b[i]==b[i+1]) continue; else {flag=1; break;} } if(flag==1) return "NO
} return "YES";
}
Seems like cookies are disabled on this browser, please enable them to open this website
Happy Ladybugs
You are viewing a single comment's thread. Return to all comments →
}