One-Liner in Python


  • 0
    R

    Use bit manipulation

    return [ reduce(lambda x,y: x + [nums[y]]*(1 if n&1<<y else 0) ,range(len(nums)), []) for n in range(pow(2,len(nums)))]
    

Log in to reply
 

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