← 返回 bytedance 的题目列表Maximum Path Sum in a Grid
类型:online_judge
Given a grid containing non-negative integers, find a path from the top-left to the bottom-right corner, such that the path has the maximum total sum of numbers. You can only move either down or right at any point in time.
Input:
An m x n grid grid where 1 <= m, n <= 100 and 0 <= grid[i][j] <= 100.
Output:
Return the path's maximum number sum.
Example:
Input:
[[5, 3, 2],
[1, 2, 1],
[1, 5, 1]]
Output:
12
Explanation: The chosen path is 5 -> 3 -> 2 -> 1 -> 5 -> 1, with a total sum of 12.
Example
Input
[[5, 3, 2], [1, 2, 1], [1, 5, 1]]