Given an integer array nums
that may contain duplicates, return all possible subsets (the power set).
The solution set must not contain duplicate subsets. Return the solution in any order.
Example 1:
Input: nums = [1,2,2]
Output: [[],[1],[1,2],[1,2,2],[2],[2,2]]
Example 2:
Input: nums = [0]
Output: [[],[0]]
Constraints:
1 <= nums.length <= 10
-10 <= nums[i] <= 10
給定一個會有重複值的整數陣列 nums
要求實做出一個演算法找出所有不重複的子陣列集合
這題跟 78. Subsets 類似
只差在會有重複值的元素
所以要如何避免窮舉出重複值就是一個關鍵
首先觀察決策樹,如下圖: