MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / subsets

Method subsets

Backtracking/subsets.py:32–53  ·  view source on GitHub ↗

:type nums: List[int] :rtype: List[List[int]]

(self, nums)

Source from the content-addressed store, hash-verified

30"""
31class Solution(object):
32 def subsets(self, nums):
33 """
34 :type nums: List[int]
35 :rtype: List[List[int]]
36 """
37 result = []
38
39 length = len(nums)
40
41 def makeSubsets(index, current_subsets):
42 if index == length:
43 return
44
45 result.append(current_subsets+[nums[index]])
46
47 makeSubsets(index+1, current_subsets+[nums[index]])
48 makeSubsets(index+1, current_subsets)
49
50
51 makeSubsets(0, [])
52
53 return result+[[]]
54

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected