Search
⌘K

Leetcode 3405. Count the Number of Arrays with K Matching Adjacent Elements

Count the number of length-n arrays with values in [1..m] that have exactly k adjacent equal pairs (equivalently exactly n-1-k transitions), returning the result mod 1e9+7. The core challenge is a combinatorics/DP counting problem: efficiently count arrangements of transition positions and value assignments under constraints up to 1e5.


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.