length tiles numbered from 0 to length - 1; right now it is on tile 0. On each move the robot does one of three things: steps to the neighbouring tile on the left, steps to the neighbouring tile on the right, or stays where it is. It must never leave the corridor.
In how many ways can the robot make exactly steps moves and end up back on tile 0? Two ways differ if their sequences of moves differ. The answer can be large, so return it modulo 10⁹ + 7.steps=2, length=3 → 2
Either stay put twice, or step right and step back: 2 ways.
steps=4, length=1 → 1
There is only one tile, so the only option is to stay put for all 4 moves.
steps=3, length=10 → 4
Stay three times, plus three ways to place one stay around a right-then-left pair: 4 in total.
steps ≤ 500length ≤ 10⁶steps=2, length=3
2
Run checks the first 3 tests in your browser. Submit checks all 68 tests on the server, hidden ones included.