816. Partition to K Equal Sum Subsets

HardRecursionRecursion

Given an integer array nums and integer k, determine if it's possible to divide nums into k non-empty subsets of equal sum. Return true/false. Input: JSON {nums, k}.

Input: JSON {nums, k}.

Output: Boolean.

Examples

Example 1
Input: {"nums":[4,3,2,3,5,2,1],"k":4}
Output: true
Explanation: (5),(1,4),(2,3),(2,3).
Example 2
Input: {"nums":[1,2,3,4],"k":3}
Output: false
Explanation: Sum=10 not divisible by 3.

Constraints

Asked by

AmazonMicrosoftGoogleMetaBloomberg
Solve this problem in the editor →