diff options
Diffstat (limited to 'progs/a510.py')
-rw-r--r-- | progs/a510.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/progs/a510.py b/progs/a510.py new file mode 100644 index 0000000..ca69f29 --- /dev/null +++ b/progs/a510.py @@ -0,0 +1,8 @@ +def max_path_sum(tri, m, n):
+ for i in range(m-1, -1, -1):
+ for j in range(i+1):
+ if (tri[i+1][j] > tri[i+1][j+1]):
+ tri[i][j] += tri[i+1][j]
+ else:
+ tri[i][j] += tri[i+1][j+1]
+ return tri[0][0]
\ No newline at end of file |