Partition into k equal subsets

Write codeHard30 min

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) -> bool
Example 1
Inputcan_partition_k_subsets([4, 3, 2, 3, 5, 2, 1], 4)
OutputTrue