Substring Match Generator
Problem statement
Write a generator that scans text from left to right and yields true whenever a substring equals pattern. Matching is literal and overlapping matches count. The pattern is nonempty.
For this finite function interface, return the collected boolean yields in discovery order. Emit one true for each matching start position and no false values. Return an empty array when there is no match.
Function
substringMatches(text: String, pattern: String) → boolean[]Examples
Example 1
text = "aaaa"pattern = "aa"return = [true,true,true]Matches start at indices 0, 1 and 2. Overlapping matches each yield true.
Example 2
text = "abc"pattern = "d"return = []No substring equals the pattern, so the generator yields nothing.
Constraints
- 0 <= text.length <= 20000
- 1 <= pattern.length <= 10000
- text and pattern contain only lowercase English letters.