Required Substrings

Given an array of strings A of size N and two integers B and C.

Let D be the number of strings of length C that contain exactly B of the strings in words as substrings.

Return D modulo (109+9).

Note: Your solution will run on multiple test cases. If you are using global variables, make sure to clear them.



Input Format

The First argument given is the string array A.
The Second argument given is integer B.
The Third argument given is integer C.

Output Format

Return the value of D modulo (10^9+9).

Constraints

1 <= N <= 6
1<= |A[i]| <= 50
Eah string consists of lowercase english alphabets ('a' - 'z').
All the N strings are distinct.
0 <= B <= N
1 <= L <= 50

For Example

Input 1:

    A = ["z","zz","zzz","zzzz"]
    B = 2
    C = 3
    
Output 1:
    50
    The only valid strings are strings of the form "#zz" or "zz#", where # is one of the letters 'a'- 'y'.

Input 2:

    A = ["uvwxyz"]
    B = 1
    C = 5
    
Output 2:
    0
    A string of length 5 cannot have a substring of length 6.
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 Required Substrings on Interview Code Editor
Sign Up
to access hints and editorial solutions for Required Substrings

Discussion


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