classSolution: defsubsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ ans = [] size = int(pow(2, len(nums))) hash_n = 1 while hash_n <= size: t = [] for i in range(len(nums)): a = 1 << i if a&hash_n: t.append(nums[i]) ans.append(t) hash_n += 1 return ans