Python Code for Zero Count (TCS Codevita) | PrepInsta

Zero Count

TCS CodeVita is a coding competition organized by TCS every year, in search of world’s best coder. This is a global level coding competition in which coders from all around the world compete for the title of World’s Best Coder. Zero Count is one of the sample problem of this year TCS CodeVita season 11 competition. 

tcs-bps-hiring

Question -:You are given a binary string B of length L which contains K ones and remaining zeros. You are required to place the K ones in the binary string in such a way that the longest consecutive zeros have the least length possible. Once such a binary string is constructed, you are required to print the length of the contiguous block of zeros, which has the largest length.

Constraints
0 <= K <= L