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

Method nearest

src/class195/Code09_Jail1.java:180–186  ·  view source on GitHub ↗
(int x, int y)

Source from the content-addressed store, hash-verified

178 }
179
180 public static int nearest(int x, int y) {
181 if (isAncestor(y, x)) {
182 return kthAncestor(x, dep[x] - dep[y] - 1);
183 } else {
184 return stjump[y][0];
185 }
186 }
187
188 public static void pathSet(int x, int y, int prisoner) {
189 if (dep[x] < dep[y]) {

Callers 1

linkMethod · 0.95

Calls 2

isAncestorMethod · 0.95
kthAncestorMethod · 0.95

Tested by

no test coverage detected