Amazon Interview Question for SDE-2s
- 0of 0 votes
You are given a String S of length N. Now, a good subsequence is one that can be represented in the form (a raised to the power i) (b raised to the power j) (c raised to the power k) where i≥1, j≥1 and k≥1. For example ,if i=2, j=1, k=3, it represents the string aabccc. In short, a good subsequence is a subsequence that first consist of- itsvks February 24, 2017 in United States
i ′a′ characters, followed by j ′b′ characters, followed by k′c′ characters, where i≥1, j≥1 and k≥1
Now, you need to find the number of good subsequences of String S. As the number of such subsequences could be rather large, print the answer Modulo
(10 raised to the power 9) + 7.
Note: Two subsequences are considered different if the set of array indexes picked for the 2 subsequences are different.
Input : abcabc
Output : 7
Valid sub sequences are(1-based indexing):
| Report Duplicate | Flag | PURGE
Open Chat in New Window