MCPcopy Index your code
hub / github.com/algorithmzuo/algorithm-journey / lca

Method lca

src/class122/Code01_MaxFlow1.java:76–97  ·  view source on GitHub ↗
(int a, int b)

Source from the content-addressed store, hash-verified

74 }
75
76 public static int lca(int a, int b) {
77 if (deep[a] < deep[b]) {
78 int tmp = a;
79 a = b;
80 b = tmp;
81 }
82 for (int p = power; p >= 0; p--) {
83 if (deep[stjump[a][p]] >= deep[b]) {
84 a = stjump[a][p];
85 }
86 }
87 if (a == b) {
88 return a;
89 }
90 for (int p = power; p >= 0; p--) {
91 if (stjump[a][p] != stjump[b][p]) {
92 a = stjump[a][p];
93 b = stjump[b][p];
94 }
95 }
96 return stjump[a][0];
97 }
98
99 public static void dfs2(int u, int f) {
100 for (int e = head[u], v; e != 0; e = next[e]) {

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected