NAJPF - Pattern Find


Your task is so simple given a string and a pattern. You find the pattern on the given string. If found print how many time found the pattern and their index. Otherwise print ‘Not Found’

Input:          

The input   line consists of a number T (1 ≤ T ≤ 50) test cases.

For each case given two string number  A,B. the string and the pattern  1 ≤|A|, |B| ≤10^6

All character will be lower case Latin character.  And |  | is the length of string.

Output:

For each case print the number  (found pattern from the given string) next line there position And Otherwise print 'Not Found' without quota.
There will a blank line between two cases.

Sample:

Input

Output

3
ababab ab
aaaaa bbb
aafafaasf aaf

3
1 3 5

Not Found

1
1

 

 

Hints:

Here all index is 1 base.


hide comments
mahbubkuet08: 2019-03-24 08:08:23

Getting RTE using RobinKarp. My bad luck. :(

az2019: 2019-02-13 17:28:05

1_hashing
2_kmp
choos(e) one of them!

Last edit: 2019-02-18 18:38:36
az2019: 2019-02-13 17:27:39


Last edit: 2019-02-13 17:31:34
ameernsr: 2019-02-12 13:10:50

ac with hashing love to use kmp toooo!

ameernsr: 2019-02-12 13:10:18

badihiujattttt

terrexo: 2019-01-07 00:42:37

AC using Rabin Karp Algo ( Hashing )

madhur4127: 2018-07-24 10:04:16

brute force worked in 0.02s, Weak test cases!

forte11: 2018-05-18 05:25:44

I use hash table!!!

rohit9934: 2018-01-20 16:31:06

simple bruteforce works in 0.9 sec.

coder271: 2018-01-16 07:02:02

learn kmp algo from geeksforgeeks


Added by:Najmuzzaman
Date:2014-10-23
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU