Easy to understand python solution using bit manipulation


  • 0
    A
        result  = []
        numsSorted = sorted(nums)
        for i in range(1 << len(nums)):
            j = 0
            cur = []
    
            while j <= i:
                if (1 << j) & i != 0:
                    cur.append(numsSorted[j])
                j+=1
            result.append(cur)
    
        return result

Log in to reply
 

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