Obsessive String

Given two string A and B consisting of lowercase english letters.
You need to find how many
ways are there to extract (k ≥ 1) non-overlapping substrings from A such that each of them contains string t as a substring

As the number of ways can be rather large print it modulo 109+7.

Note: Your solution will run on multiple test cases, Make sure to clear global variables every time.



Input Format

The First argument is string A.
The Second argument is string B.

Output Format

Return number of ways to extract(k>=1)
non-overlapping substrings from A such that each of them contains string t as a substring modulo (10^9+7).

Constraints

1 <= |A| <= 100000
1 <= |B| <= 100000

For Example

Input 1:
    A = "bcbcb" 
    B = "bc"
Output 1:
    10
    Following are the 10 ways:
    ["bc"]
    ["bcb"]
    ["bcbc"]
    ["bcbcb"]
    ["cbc"]
    ["cbcb"]
    ["bc"]
    ["bcb"]
    ["bc", "bc"]
    ["bc", "bcb"]

Input 2:
    A = "bbbc"
    B = "bbbc"
Output 2:
    1
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Obsessive String on Interview Code Editor
Sign Up
to access hints and editorial solutions for Obsessive String

Discussion


Loading...
Click here to start solving coding interview questions