![]() |
VOOZH | about |
Given binary string S of size N and a number K. The task is to find the Longest sub string of 0's in the string which is formed by repeating given string K times.
Examples:
Input : S = "100001" , K = 3
Output : 4
After repeating given string 3 time, string becomes 100001100001100001.
The longest substring of 0's is 4Input : S = "010001000", K = 4
Output : 4
Approach:
Below is the implementation of the above approach:
Time Complexity: O(n), where n is the length of the string
Auxiliary Space: O(n), for concatenating the string with itself.