CT072

YashviLab’s Multi-Word Radar

HardL8 · Quantum CoderAcceptance: 0.0%XP: 250

Archivist YashviLab searches a long scroll for several secret words at once. Count all occurrences of every supplied pattern, including overlaps. Input: text, integer k, then k lowercase patterns. Output one occurrence count per pattern in input order.

Example 1:

Input: ababa 3 a aba ba
Output: 3 2 2

Example 2:

Input: aaaa 2 aa aaa
Output: 3 2

Example 3:

Input: abc 2 x c
Output: 0 1

Constraints:

text length≤200000; total pattern length≤200000.

Tags:

strings aho-corasick trie
Loading...
Test Cases:No test cases
No test cases available.