text and a list of distinct words vocabulary. Find every place where a vocabulary word appears in text as a substring.
Describe each occurrence as a pair [i, j]: the indices of its first and last letter (0-based, both ends inclusive). Occurrences may overlap or sit inside one another.
Return the list of pairs sorted by i, and by j when the i values are equal.text="sunflower", vocabulary=["sun", "flow", "flower", "low"] → [[0, 2], [3, 6], [3, 8], [4, 6]]
"sun" spans 0–2, "flow" 3–6, "flower" 3–8, "low" 4–6. Pairs with the same start are ordered by their end.
text="aaa", vocabulary=["aa", "b"] → [[0, 1], [1, 2]]
Occurrences may overlap: "aa" appears at position 0 and at position 1. "b" does not appear at all.
text) ≤ 100vocabulary) ≤ 20vocabulary are distincttext="sunflower", vocabulary=["sun", "flow", "flower", "low"]
[[0, 2], [3, 6], [3, 8], [4, 6]]
Run checks the first 3 tests in your browser. Submit checks all 84 tests on the server, hidden ones included.