Description
Given an array of length arrLen, starting at index 0, you can move left, right, or stay. Return the number of ways to be at index 0 after exactly steps moves.
Examples
Input:
steps = 3, arrLen = 2Output:
4Explanation:
4 ways to return to 0.
Input:
steps = 1, arrLen = 3Output:
1Explanation:
With only 1 step available, there's only 1 way to return to index 0: stay at index 0 (don't move). Any other move would require at least 2 steps to return to the starting position.
Input:
steps = 4, arrLen = 5Output:
14Explanation:
With 4 steps and array length 5, there are multiple valid sequences that return to index 0 after exactly 4 moves.
Constraints
- •
1 ≤ steps ≤ 500