You are viewing a single comment's thread. Return to all comments →
Basic solution
int beautifulBinaryString(string b) { int result = 0; while (b.find("010")!=string::npos) { ++b[b.find("010")+2]; result++; } return result; }
Seems like cookies are disabled on this browser, please enable them to open this website
Beautiful Binary String
You are viewing a single comment's thread. Return to all comments →
Basic solution
int beautifulBinaryString(string b) { int result = 0; while (b.find("010")!=string::npos) { ++b[b.find("010")+2]; result++; } return result; }