(row, rows, col, cols)
| 64 | }; |
| 65 | |
| 66 | var getNeighbors = (row, rows, col, cols) => |
| 67 | [ |
| 68 | [0, 1], |
| 69 | [0, -1], |
| 70 | [1, 0], |
| 71 | [-1, 0], |
| 72 | ] |
| 73 | .map(([_row, _col]) => [row + _row, col + _col]) |
| 74 | .filter( |
| 75 | ([_row, _col]) => |
| 76 | 0 <= _row && _row < rows && 0 <= _col && _col < cols, |
| 77 | ); |
| 78 | |
| 79 | /** |
| 80 | * https://leetcode.com/problems/surrounded-regions/ |