Search Pattern
Submissions: 1882   Accuracy:

34.09%

  Difficulty: Medium   Marks: 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

** For More Input/Output Examples Use 'Expected Output' option **

Author: jain_rishabh


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.