标签:
纯递归解法
class Solution: # @param {integer[]} nums # @return {integer[][]} def subsets(self, nums): nums.sort() return self.help(nums, 0) def help(self, nums, s): ans = [] if s == len(nums) - 1: return [[],[nums[-1]]] for se in self.help(nums, s+1): ans.append(se) tmp = [nums[s]] tmp.extend(se) ans.append(tmp) return ans
标签:
原文地址:http://www.cnblogs.com/dapanshe/p/4651241.html