diff --git a/notes/13. 机器人的运动范围.md b/notes/13. 机器人的运动范围.md index dd96086e..58066d50 100644 --- a/notes/13. 机器人的运动范围.md +++ b/notes/13. 机器人的运动范围.md @@ -1,6 +1,6 @@ # 13. 机器人的运动范围 -[牛客网](https://www.nowcoder.com/practice/6e5207314b5241fb83f2329e89fdecc8?tpId=13&tqId=11219&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github) +[Leetcode](https://leetcode.cn/problems/ji-qi-ren-de-yun-dong-fan-wei-lcof/) ## 题目描述 @@ -14,20 +14,20 @@ ```java private static final int[][] next = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}}; -private int cnt = 0; +private int res = 0; private int rows; private int cols; private int threshold; private int[][] digitSum; -public int movingCount(int threshold, int rows, int cols) { - this.rows = rows; - this.cols = cols; - this.threshold = threshold; +public int wardrobeFinishing(int m, int n, int cnt) { + this.rows = m; + this.cols = n; + this.threshold = cnt; initDigitSum(); boolean[][] marked = new boolean[rows][cols]; dfs(marked, 0, 0); - return cnt; + return res; } private void dfs(boolean[][] marked, int r, int c) { @@ -36,7 +36,7 @@ private void dfs(boolean[][] marked, int r, int c) { marked[r][c] = true; if (this.digitSum[r][c] > this.threshold) return; - cnt++; + res++; for (int[] n : next) dfs(marked, r + n[0], c + n[1]); }