Skip to content

Commit 282c194

Browse files
committed
Update LCA
1 parent 2ce956b commit 282c194

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

LeastCommonAncestor.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void LCA_preprocessing(ll n) {
7979
ll i, j;
8080

8181
for(i = 1; i <= n; i++) {
82-
for(j = 0; 1 << j <= n; j++) {
82+
for(j = 0; (1 << j) <= n; j++) {
8383
binary_ancestor[i][j] = -1;
8484
}
8585
}
@@ -88,7 +88,7 @@ void LCA_preprocessing(ll n) {
8888
binary_ancestor[i][0] = parent[i];
8989
}
9090

91-
for(j = 1; 1 << j <=n; j++) {
91+
for(j = 1; (1 << j) <=n; j++) {
9292
for(i = 1; i <= n; i++) {
9393
binary_ancestor[i][j] = binary_ancestor[binary_ancestor[i][j-1]][j-1];
9494
}

0 commit comments

Comments
 (0)