Backtracking

Concept Lab
Practice Problems
Python Execution SynchronizerActive Line: 1
1
def subsets(nums):
2
    result = []
3
    path = []
4
    
5
    def backtrack(start):
6
        result.append(list(path))
7
        for i in range(start, len(nums)):
8
            path.append(nums[i])
9
            backtrack(i + 1)
10
            path.pop()
11
            
12
    backtrack(0)
13
    return result
No execution event recorded.
Custom Input:
Loading trace state...
Step 0 / 0