SPOJ NHAY

From Algorithmist
Jump to navigation Jump to search

(NHAY)- Needle in a Haystack[edit]

Summary[edit]

Given a string S and a pattern P, find all occurrences of P in S.

Explanation[edit]

This is a straightforward implementation of string matching algorithms, the Knuth-Morris-Pratt algorithm is among the easiest.

Input[edit]

2
na
banananobano
6
foobar
foo
9
foobarfoo
barfoobarfoobarfoobarfoobarfoo

Output[edit]

2
4

3
9
15
21