当前位置:网站首页>11.1-CM24 最近公共祖先
11.1-CM24 最近公共祖先
2022-07-25 18:13:00 【syc596】
CM24 最近公共祖先
最近公共祖先_牛客题霸_牛客网 (nowcoder.com)
//最近公共祖先
//根节点编号为1
//返回a,b最近公共祖先的编号
//a,b也是节点编号
import java.util.*;
public class LCA {
public int getLCA(int a, int b) {
while(a!=b){
if(a>b){
a/=2;
}else{
b/=2;
}
}
return a;
}
}边栏推荐
- Oracle uses impdp import to report an error: ora-39001: invalid parameter value ora-39000: dump file description error ora-39088: file name cannot contain path description
- Basic knowledge of documents
- Linux启动mysql报错
- Keil5 "loading PDSC debug description failed for STMicroelectronics stm32hxxxxxxx" solution
- Related operations of binary tree
- Mock服务moco系列(三)- 重定向、正则表达式、延迟、模板、事件、分模块设计
- Which real-time gold trading platform is reliable and safe?
- Use of join function in MATLAB
- Kendryte K210 在freertos上的lcd屏幕的使用
- The new version of 3dcat v2.1.3 has been released. You can't miss these three function updates!
猜你喜欢

关于云XR介绍,以及5G时代云化XR的发展机遇

Tkinter GUI address book management system

Oracle import error: imp-00038: unable to convert to environment character set handle

Related operations of binary tree

Express of nodejs simple example program

Redis source code and design analysis -- 15. RDB persistence mechanism

使用sqldeveloper连接mysql

Ch582 ble 5.0 uses Le coded broadcast and connection

Thales launches solutions to help SAP customers control cloud data

Installation and operation instructions of SVN client (TortoiseSVN)
随机推荐
Landmark buildings around the world
Sorting also needs to know the information and linked list
Basic knowledge of documents
Use of C language cjson Library
"Deprecated gradle features were used in this build, making it incompatible with gradle 6.0" problem solving
Connect to MySQL using sqldeveloper
What are the advantages of real-time cloud rendering
Optimistic lock pessimistic lock applicable scenario
OV7725 yuv 640*[email protected] 配置文件
Auditing related notes
NPDP多少分通过?如何高分通过?
How many points did NPDP pass? How to pass with high scores?
srec_cat 常用参数的使用
PHP memory management mechanism and garbage collection mechanism
MySQL lost the previous 0 after the decimal number type select
Oracle使用impdp导入报错:ORA-39001: 参数值无效 ORA-39000: 转储文件说明错误 ORA-39088: 文件名不能包含路径说明
C language libcurl cross compilation
“Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0”问题解决
超全Mavan标签详解
图的相关操作