698. Partition to K Equal Sum Subsets
Practice Partition to K Equal Sum Subsets for free on NudgeCode: Medium, Backtracking pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.
Return true if nums can be split into k non-empty groups that all have the same sum, with every element in exactly one group. Otherwise return false.
Example
nums = [4,3,2,3,5,2,1], k = 4 -> true ([5], [1,4], [2,3], [2,3])
nums = [1,2,3,4], k = 3 -> false
Constraints
- 1 <= k <= nums.length <= 16
- 1 <= nums[i] <= 10^4