Easy to read Python solution


  • 0
    T
    def subsets(input_set):
        l = len(input_set)
        if l == 1:
            return [[], [input_set[0]]]
    
        elif l > 1:
            lower_level_subsets = subsets(input_set[:l - 1])
            this_level_subsets = [subset + [input_set[-1]] for subset in lower_level_subsets]
            return lower_level_subsets + this_level_subsets
    
    

Log in to reply
 

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