|
|
back to boardRuntime error , Case 8 Why does this give runtime error #8 . n = int(raw_input()) k = int(raw_input()) dp = [[-1 for x in xrange(15)]for y in xrange(1910)] def solve(index,prev) : if(index > n ) : return 1 if(dp[index][prev] != -1) : return dp[index][prev] res = 0 start = 0 if(index == 1) : start = 1 for i in xrange(start,k) : if(prev == 0 and i == 0) : continue res = res + solve(index+1,i) dp[index][prev] = res ; return res print solve(1,0) Re: Runtime error , Case 8 Same for me, solution is python3. Re: Runtime error , Case 8 You have to check for recursion depth exceeded. Do it iterative. |
|
|