Given are two Strings P1 and P2. Each of these strings contains a pattern of zeros and ones.
The string S(n) is formed by concatenating 1,000,000 copies of P1 followed by n copies of P2.
The infinite string S is formed by concatenating the strings S(1), S(2), S(3), ... in this order.
The string T consists of the first 10^16 characters of the string S.
We are interested in substrings of T that are zeroCount characters long and contain only zeros.
Write a method that finds the first occurrence of such a substring in T, and returns the zero-based index of
its first character. In case T contains no such substring return -1.
|