Lexographically Greater Strings

Given a string C consisting of lowercase English alphabets of size A.
For each string D of length n,its beauty relative to C is defined as the
number of pairs of indexes i, j (1 ≤ i ≤ j ≤ n),
such that substring D[i..j] is lexicographically larger than substring C[i..j].

Return the count of strings D, such that their beauty relative to C equals exactly B.

Since this count can be very large you are required to return count 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 an integer A.
The Second argument is an integer B.
The Third argument is String C.

Output Format

Return the count of strings D, such that their beauty relative to C equals exactly B modulo (10^9+7).

Constraints

1 <= A <= 2000
0 <= B <= 2000

For Example

Input 1:
    A = 2 
    B = 2
    C = "yz"
Output 1:
    26

Input 2:
    A = 2 
    B = 3
    C = "yx"
Output 2:
    3
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 Lexographically Greater Strings on Interview Code Editor
Sign Up
to access hints and editorial solutions for Lexographically Greater Strings

Discussion


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