3023. Find Pattern in Infinite Stream I
You are given a binary array
pattern
and an objectstream
of classInfiniteStream
representing a 0-indexed infinite stream of bits.The class
InfiniteStream
contains the following function:
int next()
: Reads a single bit (which is either0
or1
) from the stream and returns it.Return the first starting index where the pattern matches the bits read from the stream. For example, if the pattern is
[1, 0]
, the first match is the highlighted part in the stream[0, **1, 0**, 1, ...]
.
c++
1 | /** |