Search
⌘K

Leetcode 1269. Number of Ways to Stay in the Same Place After Some Steps

Count the number of sequences of left/right/stay moves on a 1D array of length arrLen starting at index 0 that return to index 0 after exactly steps moves (answer modulo 1e9+7). This is a DP/counting problem over steps and positions — with steps ≤ 500 you can limit the positions considered to O(min(arrLen, steps)) to compute ways efficiently.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.