I am looking for an efficient algorithm to find the longest run of zeros in a binary string. My implementation is in Python 2.7, but all I require is the idea of the algorithm.
For example, given '0010011010000', the function should return 4.
I don't think there is anything better than a single pass over the string, counting the current sequence length (and updating the maximum) as you go along.
If by "binary string" you mean raw bits, you can read them one byte at a time and extract the eight bits in there (using bit shifting or masking). That does not change the overall algorithm or its complexity.
Efficient algorithm to find the largest run of zeros in a binary string?