Search
⌘K

Leetcode 2963. Count the Number of Good Partitions

Count the number of ways to split an array into contiguous parts so that all occurrences of each value lie inside a single part; this reduces to computing each value's span [first,last], merging overlapping spans into K inseparable blocks, and the answer is 2^(K-1) mod 1e9+7.


Question Timeline

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

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