Given a set of no repeating element integer array nums, which returns an array of all possible subsets (power set).
Description: Solution Set can not contain duplicate subsets.
Example:
Input: nums = [1,2,3]
Output:
[
[3],
[1],
[2],
[2,3],
[1,3],
[2,3],
[1,2 ],
[]
]
An iterator is obtained, where combinations nums is obtained in the i-th combined data, and permutations are arranged to give
class Solution(object):
def subsets(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
result = []
for i in range(len(nums)+1):
for j in itertools.combinations(nums, i):
result.append(j)
return result