← 返回 doordash 的题目列表Maximum Sum of Surrounding Paths in Matrix
类型:online_judge
doordash
Given a 2D grid matrix where each cell contains an integer value. For each cell (i, j), find the maximum sum of its surrounding paths. The surrounding paths only include connected cells in the four directions (up, down, left, right) that are continuous. Starting and ending points may not form a line. Implement a function to calculate the maximum sum of surrounding paths for each cell.
Input:
A 2D grid matrix of integers with 1 <= matrix.length, matrix[0].length <= 100.
Output:
A matrix of the maximum sum of surrounding paths for each cell.
Example:
Input:
[
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
Output:
[
[11, 16, 15],
[15, 22, 21],
[19, 28, 25]
]
Example
Input
[[1,2,3],[4,5,6],[7,8,9]]