Greetings All.

I am not sure if it’s the right place to mention this issue.

I have implemented this below solution for problem set (https://www.codechef.com/problems/GRIDS). I keep getting a run time error. I have heard that some of the problem sets have memory issues while implementing in Python unless I have the logic wrong. Here is my code & any advice about what’s missing to get an AC would be appreciated.

Thank you all.

Kind Regards

n = int(input())

input_arr = []

sols = [[0 for _ in range(n)] for _ in range(n)]

for _ in range(n):

cols = []

eles = input().split(’ ')

for l in range(len(eles)):

cols.append(int(eles[l]))

input_arr.append(cols)

sols[0][0] = input_arr[0][0]

for j in range(1 , n):

sols[0][j] = input_arr[0][j] + sols[0][j-1]

for i in range(1 , n):

sols[i][0] = input_arr[i][0] + sols[i-1][0]

for row in range(1 , n):

for col in range(1 , n):

sols[row][col] = min(sols[row-1][col], sols[row][col-1]) + input_arr[row][col]

print(sols[n-1][n-1])