### 78. Subsets

题目： 
<https://leetcode.com/problems/subsets/>


难度 : Medium


Python代码

```python
class Solution(object):
    def subsets(self, nums):
        """
        :type nums: List[int]
        :rtype: List[List[int]]
        """
        results = [[]]
        for num in nums:
            results.extend([result + [num] for result in results])
        return results
            
```


BackTrack 标准解法版


```python
class Solution:
    
    def search(self, nums, S, index):
        if index == len(nums):
            self.results.append(S)
            return
        
        self.search(nums, S + [nums[index]], index + 1)
        self.search(nums, S, index + 1)
        
    def subsets(self, nums):
        self.results = []
        self.search(nums, [], 0)
        return self.results
```

对每个元素，有两种可能，加入S和不加入S，写起来思路还是很清爽的
