Partition into k equal subsets
Your task
Given an integer list nums and an integer k, return True if nums can be partitioned into exactly k non-empty subsets all having equal sum. 1 <= k <= len(nums) <= 12, values are positive. Return a boolean.
Examples
can_partition_k_subsets(nums: list[int], k: int) -> boolExample 1
Input
can_partition_k_subsets([4, 3, 2, 3, 5, 2, 1], 4)Output
True