Find patterns
Medium Accuracy: 14.47% Submissions: 981 Points: 4

Again this time Babul has encountered a new problem. In this problem he is given a string S and another string W. Now he has to find the number times W appears in string S. For example consider S = {abcdrtbwerrcokokokd} and W = {bcd}. So here the no. of times W appears in S is 2. The first time it is found in the indexes {1,2,3} (considering 0 based indexing) and the second time it is found in the index {6,11,18}. Now as the string size increases it is difficult for him to find the occurences. So help him!!!!

Note: Once the letter has been used in forming the string W, it should not be repeated.

Input:
The first line of input contains an integer T, denoting the no of test cases. Then T test cases follow. Each test case consist of 2 lines each. The first line is the string S and the second line is the string W.

Output:
For each test case in a new line print the required output.

Constraints:
1<=T<=100
1<=|S|<=1000
1<=|W|<=|S|

Example:
Input:
2
abcdrtbwerrcokokokd
bcd
ascfret
qwer

Output:
2
0

 

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.