Python "one-liner"


  • 0
    K
        def combine(self, n, k):
            def search(cur, remain):
                if remain == 0:
                    return [[]]
                return [[c] + next
                        for c in range(cur, n+2-remain)
                        for next in search(c+1, remain-1)]
            return search(1, k)
    

Log in to reply
 

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