We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Beautiful Binary String
Beautiful Binary String
Sort by
recency
|
856 Discussions
|
Please Login in order to post a comment
🧠Problem: Beautiful Binary String
This function counts the minimum number of operations required to make a binary string "beautiful" by replacing occurrences of
'010'
with'011'
.🧪 Example Usage
✅ Notes:
find('010')
method locates the first occurrence of the pattern.'0'
to'1'
.'010'
is found.// c#
Basic solution
int beautifulBinaryString(string b) { int result = 0; while (b.find("010")!=string::npos) { ++b[b.find("010")+2]; result++; } return result; }