Please enter your email address or userHandle.
Given two strings S1 and S2, find the number of times the second string occurs in the first string, whether continuous or discontinuous.
S1 = geeksforgeeks
S2 = gks
Explaination: For the first 'g' there
are 3 ways and for the second 'g' there
is one way. Total 4 ways.
You don't need to read input or print anything. Your task is to complete the function countWays() which takes the string S1 and S2 as input parameters and returns the number of ways.
Expected Time Complexity: O(n*m) [n and m are length of the strings]
Expected Auxiliary Space: O(n*m)
1 ≤ n, m ≤ 500
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.