Jumbled Strings
Medium Accuracy: 25.0% Submissions: 4 Points: 4

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.

Example 1:

Input : S = "GEEKS"
Output: 1
"GEEKS" occurs in S only once.

Example 2:

Input: S = "AGEEKKSB"
Output: 2
Explanation: Subsequenece "GEEKS" occurs in 
S two times. First one is taking the first 
'K' into consideration and second one is 
taking second 'K'.


Your Task:
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 


to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.