当前位置:网站首页>11.1-cm24 nearest common ancestor
11.1-cm24 nearest common ancestor
2022-07-25 18:23:00 【syc596】
CM24 Recent public ancestor
Recent public ancestor _ Niuke Tiba _ Cattle from (nowcoder.com)
// Recent public ancestor
// The root node number is 1
// return a,b The number of the nearest common ancestor
//a,b Also node number
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;
}
}边栏推荐
- 想要做好软件测试,可以先了解AST、SCA和渗透测试
- C语言 整数与字符串的相互转换
- ORB_SLAM3复现——上篇
- [HAOI2015]树上操作
- 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
- Design practice of Netease strictly selecting inventory center
- Error when starting MySQL on Linux
- Analysis of regression problem, modeling and prediction
- Safe operation instructions for oscilloscope probe that must be read by engineers
- OV7725 yuv 640*[email protected] 配置文件
猜你喜欢

【网页性能优化】SPA(单页面应用)首屏加载速度慢怎么办?

Related operations of figure

Oracle使用impdp导入报错:ORA-39001: 参数值无效 ORA-39000: 转储文件说明错误 ORA-39088: 文件名不能包含路径说明

Use of LCD screen of kendryte k210 on FreeRTOS

C language -- 25 minesweeping game

Boomi won the "best CEO in diversity" and the "best company in career growth" and ranked among the top 50 in the large company category

工程师必看的示波器探头安全使用说明书

STM8S003F3 内部flash调试

7. Dependency injection

想要做好软件测试,可以先了解AST、SCA和渗透测试
随机推荐
SQL things
想要做好软件测试,可以先了解AST、SCA和渗透测试
[HAOI2015]树上操作
Use of join function in MATLAB
Could not stop Cortex-M device! please check the JTAG cable的解决办法
Good news! Ruiyun technology was awarded the member unit of 5g integrated application special committee of "sailing on the sea"
STM8S003F3 uart的使用
基于Caffe ResNet-50网络实现图片分类(仅推理)的实验复现
What are the methods of traversing arrays? What is the difference between the performance of the for loop foreach for/in for/of map and how to choose?
Jz71 jump step expansion problem
程序的编译
数二2010真题考点
Tkinter GUI address book management system
Why the future of digitalization depends on 3D real-time rendering
Problems faced by cloud XR and main application scenarios of cloud XR
C语言 cJSON库的使用
C盘空间不够 mklink解决VScode扩展迁移到其他盘
uniapp滚动条置顶效果、自定义页面滚动条的位置(整理)
结合GHS MULTI使用瑞萨E1仿真器实现对瑞萨RH850单片机的仿真调试
C语言 libcurl交叉编译