• + 0 comments

    My Python code that passed all the test cases:

    from itertools import combinations
    def solve(s):
        n = len(s)
        combs = []
        for i in range (1, n+1):
            # find all combinations of size 'i' from 's'
            temp = combinations(s, i)    
            # add those combinations to the list 'combs'
            combs += [''.join(e) for e in temp]
        combs.sort()
        return combs