Java DFS Solution beat 99.99% and sharing my thoughts!!!666
So the basic idea is start from 4 boards, for the points in the first row and column, they are definitely connect with Pacific Ocean, and for the points in the 
So the basic idea is start from 4 boards, for the points in the first row and column, they are definitely connect with Pacific Ocean, and for the points in the last row and columnm, they are connected with A Ocean. Then, run dfs first time to mark these points that is able to connect with Pacifica Ocean as \'P\', run dfs second time to find the points that has been already marked as "P", if its \'A\' then we find a point is able to connect with both P and A. Thus the total time complexity will be O(2 * m * n)\n```\nprivate static final int[][] directions = new int[][]{{0, 1}, {0, -1}, {1, 0}, {-1, 0}};\n    public List<int[]> pacificAtlantic(int[][] matrix) {\n        List<int[]> res = new ArrayList<>();\n        if (matrix == null || matrix.length == 0) return res;\n        int m = matrix.length;\n        int n = matrix[0].length;\n        char[][] visited = new char[m][n];\n          for (int col = 0; col < n; col++) {\n            dfs(matrix, 0, col, visited, \'P\', res);\n        }\n        for (int row = 0; row < m; row++) {\n            dfs(matrix, row, 0, visited, \'P\', res);\n        }\n        \n        for (int col = 0; col < n; col++) {\n            dfs(matrix, m - 1, col, visited, \'A\', res);\n        }\n        for (int row = 0; row < m; row++) {\n            dfs(matrix, row, n - 1, visited, \'A\', res);\n        }\n        return res;\n    }\n    \n    private void dfs(int[][] matrix, int row, int col, char[][] visited, char ch, List<int[]> res) {\n        if (visited[row][col] == \'P\' && ch == \'A\') res.add(new int[]{row, col});\n        visited[row][col] = ch;\n        for (int[] dir : directions) {\n            int x = row + dir[0];\n            int y = col + dir[1];\n            if (x < 0 || x >= matrix.length || y < 0 || y >= matrix[0].length || matrix[row][col] > matrix[x][y] || visited[x][y] == ch) continue;\n            dfs(matrix, x, y, visited, ch, res);\n        }\n        \n    }
[]