Company: Tower Research_22july
Difficulty: medium
Paths to a Goal Problem Description Given a number line with positions labeled from 0 to n, and a sequence of movements consisting of instructions 'r' (move right by 1) and 'l' (move left by 1), determine how many distinct subsequences of these moves will take you from a starting position s to an ending position y. Return the result modulo (10^9 + 7). Notes: A subsequence is formed by deleting zero or more elements from the original sequence without changing the order of the remaining elements. A subsequence is distinct if its sequence of characters differs from another subsequence. Subsequences with identical characters from different indices are considered the same and counted only once, e.g., the subsequence containing 'rr' in 'rrr' is only counted once. Starting at position j, an instruction 'r' moves to position j + 1, and an instruction 'l' moves to position j - 1. Example: Number line positions n: 0 to 6 Move sequence is: "rrr" Start position (s): 1 End position (y): 4 The numbe