import java.util.*;
public class LCA {
public int getLCA(int a, int b) {
if(a==b){
return a; //节点相等的时候,返回其本身即可
}else{
if(a>b){
int max=a;
return getLCA(a/2,b); //a大,所以a/2
}else{
int max=b;
return getLCA(a,b/2); //b大,所以b/2
}
}
}
}

京公网安备 11010502036488号