Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).
Note: The solution set must not contain duplicate subsets.
Example:
Input: [1,2,2]
Output:
[
[2],
[1],
[1,2,2],
[2,2],
[1,2],
[]
]
假设输入数组是{1,2,2,3}
按照之前的做法:{},{1} +2 -> {},{1},{2},{1,2} ; +2 ->{},{1},{2},{1,2},{2},{1,2},{2,2},{1,2,2} 导致 {2},{1,2} 均出现重复!!
现在是按照:
{} + 2 ->{2} +2 ->{2,2}
{1} + 2 ->{1,2} +2 ->{1,2,2};多出4个list,原来有2个list,现在是6个list。
之前每轮只加后面出现的一个新的元素 ;然后每轮再加后面出现的一个新的元素;这样肯定会导致有重复。【只加一次】
现在