LOL String

Chris has a binary string. He wants to remove the substring 101 because it looks a lot like a lol message. To do so he can make a switch operation (change 0 to a 1 or vice versa). What is the minimum number of switches Chris has to do on the string so he can remove all the sub-strings?

Details and Assumptions

If Chris is given the string 1010101 the minimum number of swich operations would be 2.

1
2
3
1010101
1000101
1000111


The answer is 45.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

展豪 張
Jul 25, 2016

Simplify use Ctrl + F. It shows there are 90 of them. Since the string is displayed twice in the browser, the answer is 90 ÷ 2 = 45 90\div 2=45

lol but nice solution

vince alek - 4 years, 4 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...