Given an array of integersnumsand a positive integerk, find whether it's possible to divide this array intoknon-empty subsets whose sums are all equal.
Example 1:
Input: nums = [4, 3, 2, 3, 5, 2, 1], k = 4
Output: True
Explanation: It's possible to divide it into 4 subsets (5), (1, 4), (2,3), (2,3) with equal sums.
至于复杂度嘛...have no idea。感觉有点像37 Sudoku solver。粗略估算,然后因为要找k个subset,所以起码k层,然后每一层的深度depends on target,如果target大的话,最坏情况可能有O(N),就是全部数字都加上才找到target。然后时间,就真难算,因为用了continue去排除一些一定不合法的选项。每次combination sum会用2^N,然后要求k个,所以O(K*2^n)