78. Subsets

78. Subsets

[Medium] “Given a set of distinct integers, nums, return all possible subsets (the power set), withotu duplicate subsets."

Link to Leetcode

Note: old solution, should review (TODO:)

Python3:

class Solution:
    def subsets(self, nums: List[int]) -> List[List[int]]:
        res = [[]]
        for num in nums:
            size = len(res)
            for i in range(size):
                res.append(res[i] + [num])
        return res