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

Method kthAncestor

src/class195/Code09_Jail1.java:171–178  ·  view source on GitHub ↗
(int x, int k)

Source from the content-addressed store, hash-verified

169 }
170
171 public static int kthAncestor(int x, int k) {
172 for (int p = 0; p < MAXP; p++) {
173 if (((k >> p) & 1) != 0) {
174 x = stjump[x][p];
175 }
176 }
177 return x;
178 }
179
180 public static int nearest(int x, int y) {
181 if (isAncestor(y, x)) {

Callers 1

nearestMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected