Update 13. 机器人的运动范围.md

题目链接改为力扣中的对应题目,题目描述和代码按该题的接口调整。
This commit is contained in:
CyC2018
2026-10-28 13:45:03 +08:00
parent 1c63f4cd05
commit 89efd7c83a
+8 -8
View File
@@ -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]);
}