Search
⌘K

Leetcode 2400. Number of Ways to Reach a Position After Exactly k Steps

Count the number of length-k sequences of ±1 moves on an infinite number line that take you from startPos to endPos — equivalently, choose how many right vs left steps produce the required net displacement. Return the count modulo 10^9+7 (zero if |endPos−startPos|>k or parity mismatches); typical solutions use combinatorics (binomial coefficients) or DP since k ≤ 1000.


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.