Problem
Distinct Number Line Moves
Learn this problemProblem statement
You are given a number line with positions labeled from 0 to n, a string s of move instructions, and two positions x and y.
A move instruction 'l' moves one step left, and 'r' moves one step right. You may choose any subsequence of s, preserving order, and execute that subsequence starting from position x. The position must always remain between 0 and n.
Two subsequences are considered the same if their resulting move strings are identical, even if they came from different indices of s.
Return the number of distinct subsequence move strings that take you from x to y, modulo 1_000_000_007.
Function
distinctMoves(s: String, n: int, x: int, y: int) → intExamples
Example 1
s = "rrlrlr"n = 6x = 1y = 2return = 7Constraints
1 <= s.length <= 10^50 <= x, y, n <= 2500scontains only'l'and'r'.
More Microsoft problems
- Authentication SystemOA · Seen Jul 2026
- Binary String Swap TimeOA · Seen Jul 2026
- Minimum Effort Task ScheduleOA · Seen Jul 2026
- Maximum Pipeline ThroughputOA · Seen Jul 2026
- Maximum Strong Team SubarrayOA · Seen Jul 2026
- Minimum Cost K-Capable ModelsOA · Seen Jul 2026
- Alphabetically Smallest PalindromeOA · Seen Jul 2026
- Maximum Reward PointsOA · Seen Jul 2026