Imagine you have two binary strings, a
and b
, given as input.
a
and b
are both of the same length.
The objective is to find the minimum number of flips required to make a
equal b
, WITHOUT a
ever having three of the same bit consecutively (e.g. 000
or 111
appearing anywhere in a
is disallowed). Also, you may flip only one bit at a time.
The input strings also never have three of the same bit appearing consecutively when they are given. b
is immutable.
For example:
a = 0011
b = 0101
0011 -> 0010 -> 0110 -> 0100 -> 0101 (output: 4)
You could not go from 0011 to 0111, because then there would be three 1
bits in the string.
I'm not sure how to approach solving this problem, honestly. I think that a solution may involve dynamic programming, through.