Python, backtracking, short and simple solution

  • 0
    class Solution(object):
        def subsets(self, nums):
            res = []
            self.helper(nums, res, [])
            return res
        def helper(self, nums, res, sub):
            for i in range(len(nums)):
                self.helper(nums[i + 1:], res, sub + [nums[i]])

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.