start on an infinite number line that includes negative numbers. Each step moves it one unit left or right.
Count the ways the token can end up at point finish after exactly steps steps. Two ways differ if their sequences of steps differ. Return the answer modulo 10⁹ + 7.start=3, finish=1, steps=4 → 4
The walk needs three steps left and one step right, and the right step can be any of the 4: 3→4→3→2→1, 3→2→3→2→1, 3→2→1→2→1, 3→2→1→0→1.
start=2, finish=2, steps=3 → 0
Every step flips the parity of the position, so an odd number of steps can never bring you back to where you started.
start, finish ≤ 1000steps ≤ 1000start=3, finish=1, steps=4
4
Run checks the first 3 tests in your browser. Submit checks all 41 tests on the server, hidden ones included.