Place ones as far apart as possible to minimize consecutive zeros.
To minimize the length of the longest consecutive zeros in a binary string with K ones, place the K ones as far apart as possible. This can be achieved by placing the first one at the beginning of the string, the second one at the kth position from the end of the string, the third one at the 2kth position from the end, and so on. This will ensure that the zeros in between the ones are as far apart as possible, minimizing the length of the longest consecutive zeros.
Here's the algorithm to determine the length of the longest consecutive zeros:
1. Initialize the 'longestZeros' variable to 0.
2. Iterate through the binary string, starting from the end.
3. If the current character is '1', update the 'longestZeros' variable with the current index. This is because the current position is the beginning of a new block of zeros.
4. Return the value of the 'longestZeros' variable.