(heights, row, rows, col, cols, isReachable, queue)
| 214 | .map(() => new Array(cols).fill(false)); |
| 215 | |
| 216 | var checkNeighbor = (heights, row, rows, col, cols, isReachable, queue) => { |
| 217 | isReachable[row][col] = true; |
| 218 | |
| 219 | for (const [_row, _col] of getNeighbors(row, rows, col, cols)) { |
| 220 | if (isReachable[_row][_col]) continue; |
| 221 | |
| 222 | const isLower = heights[_row][_col] < heights[row][col]; |
| 223 | if (isLower) continue; |
| 224 | |
| 225 | queue.enqueue([_row, _col]); |
| 226 | } |
| 227 | }; |
| 228 | |
| 229 | var getNeighbors = (row, rows, col, cols) => |
| 230 | [ |