An integer array nums of length n and an integer k are given. Randomly divide nums into k groups such that every group contains exactly n / k values.
Every value in nums must be placed into exactly one group, and no value may be repeated across groups. The result should be k lists of identical size, representing one possible random partition.
Because the partition is random, more than one output may be valid for the same input. You may assume that n is always divisible by k.
Constraints:
nums are integers in the range [-1000, 1000].Example 1:
nums = [1, 2, 3, 4, 5, 6], k = 2
[[2, 5, 6], [1, 3, 4]]
This is one valid partition because both lists have size 3 and together contain every value from the input exactly once.
Example 2:
nums = [1, 2, 3, 4], k = 4
[[1], [2], [3], [4]]
Example 3:
nums = [1, 1, 2, 2], k = 2
[[2, 1], [1, 2]]