Python 4 lines solution.

  • 0

    Very simple Python Solution. Using recursion methods. Not sure if anyone has posted.

    class Solution(object):
        def subsets(self, S):
            :type S: List[int]
            :rtype: List[List[int]]
            if len(S)==0:return [[]]
            R = self.subsets(S[1:])
            R1= [[S[0]]+R[i] for i in range(len(R))]
            return R+R1

Log in to reply

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