Search
⌘K

Leetcode 2518. Number of Great Partitions

Count the number of ways to assign each element to one of two ordered groups so both group sums are at least k (mod 1e9+7). Key trick: instead of enumerating partitions, subtract assignments where a group's sum < k by counting subsets with sum < k using a knapsack/subset-sum DP (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.