Find Bit whose minimum sequence flips makes all bits same - GeeksforGeeks
Find Bit whose minimum sequence flips makes all bits same
Given a binary string consisting only of 1's and 0's. Find the bit (output is either 1 or 0)whose the minimum number of contiguous sequence flips can make all bits of the string same.
Here, contiguous sequence flip means flipping a substring or 0s or 1s. For Example, in the string "00011110001110", in one flip we can change the string to "11111110001110". The first three continuous zeros are changed to 1.
Note:
- In one flip we can change any continuous sequence of this string.
- If both 0s and 1s are possible, print the one which comes last.
- The task is to simply print the bit 1 or 0 for which minimum sequence flips will make all bits same.
Read full article from Find Bit whose minimum sequence flips makes all bits same - GeeksforGeeks
No comments:
Post a Comment