my easy python solution, iteration and easy understanding

  • 0

    class Solution(object):
    def combinationSum3(self, k, n):
    :type k: int
    :type n: int
    :rtype: List[List[int]]

        return self.numberSum(k,n,0)
    def numberSum(self,k,n,start):
        if k <=0:
            return [[]]
        elif k == 1:
            if n<=9 and n>start:
                return [[n]]
                return [[]]
        hit = []
        for i in range(start+1,10):
            maybeSubList = self.numberSum(k-1,n-i,i)
            for li in maybeSubList:
                if li != [] :
        return hit

Log in to reply

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