Search Pattern
Medium Accuracy: 35.08% Submissions: 2670 Points: 4

Given two strings, one is a text string and other is a pattern string. The task is to print the indexes of all the occurences of pattern string in the text string. For printing, Starting Index of a string should be taken as 1.

Note: Strings contain only lower case alphabets.

Input:
First line of the input contains an integer 'T' denoting the total number of test cases. Then T test cases follow. Each test consists of two lines. First line of each test case contains the text string. Second line of each test case contains the pattern string.

Output:
Print indexes all the occurences of the pattern strings in the text string in a single line seprated by spaces.
Print -1 if no pattern found.

Constraints:
1 <= T <= 100
1 <= Sizeof of text String <= 10000
1 <= Sizeof pattern String <= Sizeof text String

Example:
Input :

2
batmanandrobinarebatfriends
bat
abcsdu
edu

Output :
1 18
-1

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.