Skip to content

Commit c7982ee

Browse files
committed
modify code
1 parent 51e472b commit c7982ee

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/class118/Code01_KthAncestor.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,7 @@ public static void dfs(int u, int f) {
7171
stjump[u][p] = stjump[stjump[u][p - 1]][p - 1];
7272
}
7373
for (int e = head[u]; e != 0; e = next[e]) {
74-
// 其实这里不用加这个判断,因为可以直接建有向图
75-
// 那么从u开始走是不可能遇到f的
76-
// 但如果是双向图就需要加这个判断了,防止走回头路
77-
// 所以一律加上作为提醒
78-
if (to[e] != f) {
79-
dfs(to[e], u);
80-
}
74+
dfs(to[e], u);
8175
}
8276
}
8377

0 commit comments

Comments
 (0)