One line python code by bit manipulate

  • 0
    class Solution(object):
        def subsets(self, nums):
            :type nums: List[int]
            :rtype: List[List[int]]
            return [[nums[j-1] for j in xrange(len(nums)) if 2**j & i != 0] for i in xrange(2**len(nums))]

Log in to reply

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