Count Secured Strings
Learn this problemProblem statement
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! 💜
Function
amazonCountSecuredStrings(s: String, t: String) → intExamples
Example 1
s = "aba"t = "ab"return = 3
Example 2
s = "bab"t = "ab"return = 5
Constraints
1 <= |s| <= 10^51 <= |t| <= 100s and tconsists of lowercase English letters.
More Amazon problems
- Drone Delivery RouteOA · Seen Aug 2026
- Package Dependency OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Aug 2026
- Unfulfilled Customers by Inventory PriorityOA · Seen Aug 2026
- Calculate Beauty ValuesOA · Seen Aug 2026
- Maximize Distance to the Closest Occupied SeatONSITE INTERVIEW · Seen Aug 2026
- Package Delivery SystemOA · Seen Aug 2026
- Select Least Resource TasksOA · Seen Aug 2026
- Maximum Length-K Window Sum over Sparse SegmentsOA · Seen Aug 2026