Given the data below, find the highest value route moving from bottom-left to top-right.
[{ 0, 0, 0, 6 },
{ 2, 0, 0, 2 },
{ 0, 1, 1, 1 },
{ 3, 0, 0, 0 }]
go can only move right (east) or up (north)
Highest value route here is 3 -> 0 -> 1 -> 1 -> 1 -> 2 ->6 = 14
How should I approach this problem. Is my approach below as pseudo-code correct?
max = 0
array = defined_array
i = len(array)
k = 0
def path(i,j):
total = 0
for j in range(4):
k = j;
total = total + int(array[i][j])
if total > max:
max = total
return path(--i,k)
key= 3
def path(i,j):
for i in range(i):
for j in range(array[i]):
total = total + array[i][j]