In a given string of 0s and 1s, if you flip only one 0 to 1, what would be the longest contiguous string of 1s possible? In the case of "0010110100", the answer would be 4 and attained by flipping bit number 7 from 0 to 1. What's the most efficient way you can solve this programatically?
Comments:
Addison - 10 years, 3 months ago
Is there an implied quantity of having to find the LAST, longest sequence of ones? Technically the string above contains a tie between bit 4 and bit 7
reply permalink