MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / getDist

Method getDist

src/class185/Code01_Wave1.java:185–187  ·  view source on GitHub ↗
(int x, int y)

Source from the content-addressed store, hash-verified

183 }
184
185 public static int getDist(int x, int y) {
186 return dep[x] + dep[y] - (dep[getLca(x, y)] << 1);
187 }
188
189 // 找重心需要计算子树大小的递归版,java会爆栈,C++不会
190 public static void getSize1(int u, int fa) {

Callers 2

addMethod · 0.95
queryMethod · 0.95

Calls 1

getLcaMethod · 0.95

Tested by

no test coverage detected