diff --git a/docs/notes/Leetcode 题解 - 搜索.md b/docs/notes/Leetcode 题解 - 搜索.md index 2e0729e9..b884a189 100644 --- a/docs/notes/Leetcode 题解 - 搜索.md +++ b/docs/notes/Leetcode 题解 - 搜索.md @@ -503,13 +503,12 @@ Return: 左边和上边是太平洋,右边和下边是大西洋,内部的数字代表海拔,海拔高的地方的水能够流到低的地方,求解水能够流到太平洋和大西洋的所有位置。 ```java - private int m, n; private int[][] matrix; private int[][] direction = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; -public List pacificAtlantic(int[][] matrix) { - List ret = new ArrayList<>(); +public List> pacificAtlantic(int[][] matrix) { + List> ret = new ArrayList<>(); if (matrix == null || matrix.length == 0) { return ret; } @@ -532,7 +531,7 @@ public List pacificAtlantic(int[][] matrix) { for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (canReachP[i][j] && canReachA[i][j]) { - ret.add(new int[]{i, j}); + ret.add(Arrays.asList(i, j)); } } } diff --git a/notes/Leetcode 题解 - 搜索.md b/notes/Leetcode 题解 - 搜索.md index 38945d90..4ce16d89 100644 --- a/notes/Leetcode 题解 - 搜索.md +++ b/notes/Leetcode 题解 - 搜索.md @@ -503,13 +503,12 @@ Return: 左边和上边是太平洋,右边和下边是大西洋,内部的数字代表海拔,海拔高的地方的水能够流到低的地方,求解水能够流到太平洋和大西洋的所有位置。 ```java - private int m, n; private int[][] matrix; private int[][] direction = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}}; -public List pacificAtlantic(int[][] matrix) { - List ret = new ArrayList<>(); +public List> pacificAtlantic(int[][] matrix) { + List> ret = new ArrayList<>(); if (matrix == null || matrix.length == 0) { return ret; } @@ -532,7 +531,7 @@ public List pacificAtlantic(int[][] matrix) { for (int i = 0; i < m; i++) { for (int j = 0; j < n; j++) { if (canReachP[i][j] && canReachA[i][j]) { - ret.add(new int[]{i, j}); + ret.add(Arrays.asList(i, j)); } } }