1681. Minimum Incompatibility
https://leetcode.com/problems/minimum-incompatibility
Description
You are given an integer array nums
and an integer k
. You are asked to distribute this array into k
subsets of equal size such that there are no two equal elements in the same subset.
A subset's incompatibility is the difference between the maximum and minimum elements in that array.
Return the minimum possible sum of incompatibilities of the k
subsets after distributing the array optimally, or return -1
if it is not possible.
A subset is a group integers that appear in the array with no particular order.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= k <= nums.length <= 16
nums.length
is divisible byk
1 <= nums[i] <= nums.length
ac
Previous1680. Concatenation of Consecutive Binary NumbersNext1682. Longest Palindromic Subsequence II
Last updated