MCPcopy Index your code
hub / github.com/doocs/leetcode / dfs

Method dfs

solution/0400-0499/0489.Robot Room Cleaner/Solution.java:29–45  ·  view source on GitHub ↗
(int i, int j, int d)

Source from the content-addressed store, hash-verified

27 }
28
29 private void dfs(int i, int j, int d) {
30 robot.clean();
31 vis.add(List.of(i, j));
32 for (int k = 0; k < 4; ++k) {
33 int nd = (d + k) % 4;
34 int x = i + dirs[nd], y = j + dirs[nd + 1];
35 if (!vis.contains(List.of(x, y)) && robot.move()) {
36 dfs(x, y, nd);
37 robot.turnRight();
38 robot.turnRight();
39 robot.move();
40 robot.turnRight();
41 robot.turnRight();
42 }
43 robot.turnRight();
44 }
45 }
46}

Callers 1

cleanRoomMethod · 0.95

Calls 3

addMethod · 0.45
containsMethod · 0.45
moveMethod · 0.45

Tested by

no test coverage detected