Go
func getMaxValue(grid [][]int) int {
var m,n int
m=len(grid)
if m==0{
return 0
}
n=len(grid[0])
if n==0{
return 0
}
a:=make([]int,n)
a[0]=grid[0][0]
for i:=1;i<n;i++{
a[i]=a[i-1]+grid[0][i]
}
for i:=1;i<m;i++{
a[0]+=grid[i][0]
for j:=1;j<n;j++{
if a[j-1]>a[j]{
a[j]=a[j-1]+grid[i][j]
}else{
a[j]+=grid[i][j]
}
}
}
return a[n-1]
}