javascript easy dfs
```\nvar pacificAtlantic = function(matrix) {\n    let res = [];\n    let min = -Infinity;\n    let rows = matrix.length;\n    let cols = matrix[0].length; \n  
```\nvar pacificAtlantic = function(matrix) {\n    let res = [];\n    let min = -Infinity;\n    let rows = matrix.length;\n    let cols = matrix[0].length; \n    let pacific = new Array(rows).fill().map(() => new Array(cols).fill(0));\n    let atlantic = new Array(rows).fill().map(() => new Array(cols).fill(0));\n    \n    // left & right\n    for (let row = 0; row < rows; row ++) {\n        dfs(matrix, row, 0, min, pacific)\n        dfs(matrix, row, matrix[0].length - 1, min, atlantic)\n    }\n    // top & bottom\n    for (let col = 0; col <  cols; col ++) {\n        dfs(matrix, 0, col, min, pacific)\n        dfs(matrix, matrix.length - 1, col, min, atlantic)\n    }\n    \n    for (let row = 0; row < rows; row ++) {\n        for (let col = 0; col < cols; col ++) {\n            if (pacific[row][col] == 1 && atlantic[row][col] == 1) {\n                res.push([row, col])\n            }\n        }\n    }\n    return res;\n    \n};\n\nconst dfs = (matrix, r, c, prevVal, ocean) => {\n    // 1. Check necessary condition.\n    if (r < 0 || c < 0 || r > matrix.length - 1 || c > matrix[0].length - 1) return;\n    if (matrix[r][c] < prevVal) return;\n    if (ocean[r][c] == 1) return;\n    \n    // 2. Process call.\n    ocean[r][c] = 1;\n    \n    // 3. Call dfs as needed.\n    dfs (matrix, r - 1, c, matrix[r][c], ocean);\n    dfs (matrix, r + 1, c, matrix[r][c], ocean);\n    dfs (matrix, r, c - 1, matrix[r][c], ocean);\n    dfs (matrix, r, c + 1, matrix[r][c], ocean);\n}
['Depth-First Search', 'JavaScript']