Exercise
Given an array of binary numbers, find the minimum number of flips (inversions) required to get an alternating version of it.
Solution
Given that we are dealing with binary numbers, there are 2 possible alternating versions of it, the one that starts with 0, and the one that starts with 1. This means that the input array should be compared with these 2 possibilities, get the number of required flips on each of them, and finally the result will be the minimum of these 2 counts.