94% Python3 solution

  • 0
    class Solution:
        def subsets(self, nums):
            :type nums: List[int]
            :rtype: List[List[int]]
            res = [nums]
            cur = [tuple(nums)]
            l = 0
            while l < len(nums):
                new_cur = set()
                for n in cur:
                    for i in range(len(n)):
                        new_cur.add(n[:i] + n[i+1:])
                cur = new_cur
                for n in cur:
                l += 1
            return res

Log in to reply

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