Find patterns
Submissions: 842   Accuracy:

14.43%

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

 

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

Author: Prithwish Dasgupta


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.