← 返回 bytedance 的题目列表岛屿流向边界
类型:online_judge
Given a 2D grid where each cell represents a height, find the points in each row that can flow from high to low to the boundary of the grid. Each point can flow to an adjacent cell in the up, down, left, or right direction if and only if the adjacent cell's height is not greater than the current cell's height. Return a list of coordinates of these points.
Input:
A 2D integer grid representing the height at each point.
Output:
A list of lists, containing the coordinates of points in each row that can flow from high to low to the boundary.
Example:
Input:
grid = [
[9, 8, 7],
[6, 5, 4],
[3, 2, 1]
]
Output:
[[0, 0], [1, 0], [2, 0]]
Constraints:
1 <= grid.length, grid[i].length <= 50
0 <= grid[i][j] <= 10000
Example
Input
[[9, 8, 7], [6, 5, 4], [3, 2, 1]]