Ways Back to the Charging Pad
Preview mode. Log in to edit, run, submit, and save progress.
Medium
Ways Back to the Charging Pad
A small robot starts on cell 0 of a straight corridor with cells numbered from 0 to cells - 1. In one move, it can stay in place, move one cell left, or move one cell right. It cannot leave the corridor. Return the number of different move sequences that place the robot back on cell 0 after exactly moves moves. Return the answer modulo 10^9 + 7.
Examples
Example 1
Input:
moves = 3, cells = 2
Output:
4
Approach hint
After t moves, positions greater than t cannot be reached.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
solution.cpp