Instructions
User Manual:
Open the PDF directly: View PDF .
Page Count: 2
BeautifulBinary
String
Alicehasabinarystring, ,oflength .Shethinksabinarystringisbeautifulifandonlyifitdoesn'tcontain
thesubstring .
Inonestep,Alicecanchangea toa (orvice-versa).Countandprinttheminimumnumberofsteps
neededtomakeAliceseethestringasbeautiful.
InputFormat
Thefirstlinecontainsaninteger, (thelengthofbinarystring ).
Thesecondlinecontainsasinglebinarystring, ,oflength .
Constraints
Eachcharacterin .
OutputFormat
Printtheminimumnumberofstepsneededtomakethestringbeautiful.
SampleInput0
7
0101010
SampleOutput0
2
SampleInput1
5
01100
SampleOutput1
0
SampleInput2
10
0100101010
SampleOutput2
3
Explanation
SampleCase0:
Inthissample,
Thefigurebelowshowsawaytogetridofeachinstanceof :
Becausewewereabletomakethestringbeautifulbychanging characters( and ),weprint .
SampleCase1:
Inthissample
Thesubstring doesnotoccurin ,sothestringisalreadybeautifulandweprint .