(row, rows, col, cols)
| 59 | }; |
| 60 | |
| 61 | var getNeighbors = (row, rows, col, cols) => |
| 62 | [ |
| 63 | [0, 1], |
| 64 | [0, -1], |
| 65 | [1, 0], |
| 66 | [-1, 0], |
| 67 | ] |
| 68 | .map(([_row, _col]) => [row + _row, col + _col]) |
| 69 | .filter( |
| 70 | ([_row, _col]) => |
| 71 | 0 <= _row && _row < rows && 0 <= _col && _col < cols, |
| 72 | ); |
| 73 | |
| 74 | /** |
| 75 | * https://leetcode.com/problems/rotting-oranges/ |