Python 2d solution


#1

class Solution:

# @param A : integer
# @param B : integer
# @return an integer
def solve(self, A, B):
    if(A==0 and B==0):
        return 1
    if(A==0 or B==0):
        return 0
    dct=[[0 for i in range(B+1)] for j in range(A+1)]
    for i in range(1,10):
        if(i<=B):
            dct[1][i]=1
    for i in range(1,A):
        for j in range(B+1):
            for k in range(0,10):
                if(j+k<=B):
                    dct[i+1][j+k]+=dct[i][j]
    return dct[A][B]%1000000007