Leetcode 78 question potential solution:
class Solution(object):
def __init__(self):
self.map = {}
def helper(self, count, nums, vals, result):
if count == 0:
result += [vals]
for i in range(len(nums)):
self.helper(count - 1, nums[i+1:], vals + [nums[i]], result)
def subsets(self, nums):
result = []
result.append([])
for count in range(1,len(nums)+1):
self.helper(count, nums, [], result)
return result
For the above solution, will the time complexity be O(2^n) or will it be O(n * 2^n) ?