C# DFS/BFS solutions
DFS\n\npublic class Solution {\n    public IList<IList<int>> PacificAtlantic(int[][] matrix) {\n        \n        List<IList<int>> res = new List<IList<int>>();
**DFS**\n```\npublic class Solution {\n    public IList<IList<int>> PacificAtlantic(int[][] matrix) {\n        \n        List<IList<int>> res = new List<IList<int>>();\n        if(matrix == null || matrix.Length == 0)\n            return res;\n        \n        int m = matrix.Length, n = matrix[0].Length;\n        bool[,] pacific = new bool[m,n];\n        bool[,] atlantic = new bool[m,n];\n        \n        for(int row = 0; row < m; row++)\n        {\n            DFS(row, 0, matrix, pacific, matrix[row][0]);\n            DFS(row, n - 1, matrix, atlantic, matrix[row][n - 1]);\n        }\n\n        for(int col = 0; col < n; col++)\n        {\n            DFS(0 , col,matrix, pacific, matrix[0][col]);\n            DFS(m - 1, col, matrix, atlantic, matrix[m - 1][col]);        \n        }\n        \n        for(int i = 0; i < m; i++)\n        {\n            for(int j = 0; j < n; j++)\n            {\n                if(pacific[i,j] && atlantic[i,j])\n                    res.Add(new List<int>(){i,j});\n            }\n        }\n  \n        return res;        \n    }\n    \n    private void DFS(int row, int col, int[][] matrix, bool[,] reach, int prev)\n    {\n        int m = matrix.Length, n = matrix[0].Length;\n        \n        if(row < 0 || row >= m || col < 0 || col >= n || reach[row,col] || matrix[row][col] < prev)\n            return;\n        \n        reach[row,col] = true;\n        DFS(row, col + 1, matrix, reach, matrix[row][col]);\n        DFS(row, col - 1, matrix, reach, matrix[row][col]);\n        DFS(row + 1, col, matrix, reach, matrix[row][col]);\n        DFS(row - 1, col, matrix, reach, matrix[row][col]);\n    }\n}\n```\n\n**BFS**\n```\npublic class Solution {\n    public IList<IList<int>> PacificAtlantic(int[][] matrix) {\n        \n        List<IList<int>> res = new List<IList<int>>();\n        if(matrix == null || matrix.Length == 0)\n            return res;\n        \n        int m = matrix.Length, n = matrix[0].Length;\n        Queue<(int,int)> queueP = new Queue<(int,int)>();\n        Queue<(int,int)> queueA = new Queue<(int,int)>();\n        bool[,] pacific = new bool[m,n];\n        bool[,] atlantic = new bool[m,n];\n        \n        for(int row = 0; row < m; row++)\n        {\n            queueP.Enqueue((row, 0));\n            pacific[row,0] = true;\n            \n            queueA.Enqueue((row, n - 1));   \n            atlantic[row,n - 1] = true;\n        }\n\n        for(int col = 0; col < n; col++)\n        {\n            queueP.Enqueue((0 , col));\n            pacific[0,col] = true;\n            \n            queueA.Enqueue((m - 1, col));\n            atlantic[m - 1,col] = true;\n        }\n\n         BFS(queueP, matrix, pacific);   \n         BFS(queueA, matrix, atlantic);\n        \n        for(int i = 0; i < m; i++)\n        {\n            for(int j = 0; j < n; j++)\n            {\n                if(pacific[i,j] && atlantic[i,j])\n                    res.Add(new List<int>(){i,j});\n            }\n        }\n  \n        return res;        \n    }\n    \n    private void BFS(Queue<(int,int)> queue, int[][] matrix, bool[,] reach)\n    {\n        int m = matrix.Length, n = matrix[0].Length;\n        int[,] dir = new int[,]{{-1, 0}, {1, 0}, {0, 1}, {0, -1}};\n        \n        while(queue.Count > 0)\n        {      \n            var curr = queue.Dequeue();\n            for(int i = 0; i < 4; i++)\n            {\n                int nextRow = curr.Item1 + dir[i,0];\n                int nextCol = curr.Item2 + dir[i,1];\n                \n                if(nextRow >= 0 && nextRow < m && nextCol >= 0 && nextCol < n && !reach[nextRow,nextCol]\n                  && matrix[curr.Item1][curr.Item2] <= matrix[nextRow][nextCol])\n                {\n                    queue.Enqueue((nextRow,nextCol));\n                    reach[nextRow, nextCol] = true;\n                }\n            }\n        }\n    }\n}\n```
[]