1634. [算法课分支限界法]Partition to K Equal Sum Subsets

Given an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal.

输入

4 3 2 5 1

3

输出

true

Explanation: It's possible to divide it into 3 subsets (5), (1, 4), (2,3) with equal sums.

提示

1 <= k <= nums.length <= 16

1 <= nums[i] <= 10

The frequency of each element is in the range [1, 4].

登录以提交代码。
单点时限 1 秒
内存限制 256 MB
提交 2019
通过 967