In an Amazon security analysis task, two passwords have been generated, but they may be differ in length. One password is generated by a customer, and the other by an internal system. The customer wants to determine how many secured variations of the passwords exist module 10^9 + 7.
An secured variation of the passwords is defined as a subsequence of customer's password which is lexicographically greater than system generated password.
Formally:
The task is to count how many susequences of password s are lexicographically greater than password t. Since the answer can be large, return the result module (%) 10^9 + 7. More specifically, if result represents the required number of subsequences, then return the remainder when result is divided by 10^9 + 7.
Note
x[i] > y[i] at the first position where x and y differ. or|x| > |y| and y is a prefix of x (where |x| denotes the length of password x).💜 Thanks a jillion, spike! 💜
s = "aba" t = "ab" return = 3

s = "bab" t = "ab" return = 5

1 <= |s| <= 10^51 <= |t| <= 100s and tconsists of lowercase English letters.
- Count Promotional PeriodsOA · Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Get Minimum AmountOA · Seen Jun 2026
- Find Minimum CostOA · Seen Jun 2026
- Get Smallest Base SegmentOA · Seen Jun 2026
- Select Least Resource TasksOA · Seen Jun 2026
- Product Category Group SizesPHONE SCREEN · Seen May 2026
- Count Connected ComponentsPHONE SCREEN · Seen May 2026
public int amazonCountSecuredStrings(String s, String t) {
// write your code here
}