Python code why this will give maximum depth reach error


#1
def knapsack(self,B,A,C,n):
    if n==0 or C==0:
        return 0
    if self.t[n][C]!=-1:
        return self.t[n][C]
    else:
        if B[n-1] <= C:
            self.t[n][C] = max(A[n-1]+ self.knapsack(B,A,C-B[n-1],n-1),self.knapsack(B,A,C,n-1))
            return self.t[n][C]
        else:
            self.t[n][C] = self.knapsack(B,A,C,n-1)
            return self.t[n][C]

def solve(self, A, B, C):
    n=len(A)
    self.t = [ [-1]*(C+2) for j in range(0,n+2)]
    # print(self.t)
    return self.knapsack(B,A,C,n)