Add files via upload
This commit is contained in:
parent
89552da91f
commit
9717145ad9
@ -1676,7 +1676,19 @@
|
||||
"collapsed": true
|
||||
},
|
||||
"outputs": [],
|
||||
"source": []
|
||||
"source": [
|
||||
"def maxpath(M):\n",
|
||||
" if not M: return 0\n",
|
||||
" R, C = len(mat), len(mat[0])\n",
|
||||
" totals = [[inf] * C for r in range(R)]\n",
|
||||
" for r in range(R):\n",
|
||||
" for c in range(C):\n",
|
||||
" totals[r][c] = M[r][c] + min(totals[r1][c1] for (r1, c1) in neighbors(r, c))\n",
|
||||
" return totals[r = 1][c - 1], totals\n",
|
||||
"\n",
|
||||
"def neighbors(r, c):\n",
|
||||
" if r"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
|
Loading…
Reference in New Issue
Block a user