Rearrange every occurrence in nums into a two-dimensional array. Each row must be nonempty and contain distinct integers, and the total number of rows must be as small as possible. Return any array that meets these requirements. Rows may have different lengths, and the order of rows and values does not matter.
Example 1:
Input: nums = [2,1,2,3,1]
Output: [[1,2,3],[1,2]]Explanation: The values 1 and 2 each appear twice, so at least two rows are required. The rows [1,2,3] and [1,2] use every occurrence and have no repeated value within a row.
Example 2:
Input: nums = [1,1,1]
Output: [[1],[1],[1]]Explanation: Each row can contain only one copy of 1. Three copies therefore require three rows, each containing [1].
Example 3:
Input: nums = [3,1,2]
Output: [[1,2,3]]Explanation: All values are different, so one row containing [1,2,3] uses the entire input. No answer can use fewer than one row.
Constraints:
1 <= nums.length <= 2001 <= nums[i] <= nums.length