Please enter your email address or userHandle.
You are provided an input string S and the string “GEEKS” . Find the number of ways in which the subsequence “GEEKS” can be formed from the string S.
Input : S = "GEEKS"
"GEEKS" occurs in S only once.
Input: S = "AGEEKKSB"
Explanation: Subsequenece "GEEKS" occurs in
S two times. First one is taking the first
'K' into consideration and second one is
taking second 'K'.
You don't need to read or print anything. Your task is to complete the function TotalWays() which takes string S as input paramater and returns total ways modulo 109 + 7.
Expected Time Complexity : O(N * K) where N is length of string and K is constant.
Expected Space Complexity: O(N * K)
1 <= Length od string <= 10000
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.