Description
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:
1 | Input: [1,2,2] |
解法
时间复杂度为O(2^n)次方,因为最多可能有2^n次方种可能的组合,所以遍历2^n次方次,每次根据对应2进制数的i位确定是否选取第i位的数,注意,list判断重复需要进行排序后再判断
具体代码如下:
1 | class Solution { |