Search
⌘K

Leetcode 3179. Find the N-th Value After K Seconds

Starting from an array of n ones, apply k rounds of replacing each element by the prefix sum up to that index and return a[n-1] modulo 1e9+7. Key insight: the value equals the binomial coefficient C(n+k-1, k), so the problem reduces to computing that combination mod 1e9+7 (n,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.