当前位置:网站首页>2022.7.25-----leetcode.919
2022.7.25-----leetcode.919
2022-07-26 02:05:00 【路Lu727】
TreeNode root;
Deque<TreeNode> q;//存储最后一个节点的父节点到最后节点
public CBTInserter(TreeNode root) {
this.root=root;
q=new ArrayDeque<>();
if(root!=null)
q.add(root);
while(!q.isEmpty()){
TreeNode n=q.getFirst();
if(n.left!=null)
q.add(n.left);
else break;
if(n.right!=null)
q.add(n.right);
else break;
q.poll();
}
}
public int insert(int val) {
TreeNode n=q.getFirst();
if(n.left==null){
n.left=new TreeNode(val);
q.add(n.left);
}else{
n.right=new TreeNode(val);
q.add(n.right);
q.poll();
}
return n.val;
}
public TreeNode get_root() {
return root;
}边栏推荐
- # Dest0g3 520迎新赛(更新中)
- [C language brush leetcode] 443. Compressed string (m)
- Alibaba cloud redis development specification
- 【2020】【论文笔记】磁控溅射法生长Bi2Te3/CoFeB双层异质结——
- Move bricks (greedy perturbation + 01 backpack)
- JS add random pixel noise background to the page
- 2022-07-17
- (CVPR 2019) GSPN: Generative Shape Proposal Network for 3D Instance Segmentation in Point Cloud
- 1205 Lock wait timeout exceeded; Try restarting transaction processing
- 2022-07-17
猜你喜欢

Implementation of C iterator

E. Split into two sets

Navica tool imports remote MySQL into local MySQL database

【独立站建设】shopify卖家:学会这几点,网上商店销量翻倍!

Ti AM335X工控模块矩阵键盘电路的设计与驱动移植

Ti am335x industrial control module uses the Debian system of beaglebone (BBB)

Are you still using ==0 null equal to judge null values? How much do you know about isempty and isblank

ggplot2学习总结
![[independent station construction] Shopify seller: learn these points and double the sales volume of online stores!](/img/52/8c1520db38ffa8927e975b6f244a65.png)
[independent station construction] Shopify seller: learn these points and double the sales volume of online stores!

一款可插拔的AM335X工控模块板载wifi模块
随机推荐
Build embedded development environment and FRP penetration under win
阿里云Redis开发规范
What are the functions of cloud notes, and how do browsers add cloud note plug-ins
Remember a laravel problem script @php artist package:discover handling the post autoload dump event returned with
Mark and lightbulbs (thinking)
[C language brush leetcode] 146. LRU cache (m)
DQN Pytorch示例
BGP knowledge points summary
I.MX6UL核心模块使用连载-RS485测试 (十)
SQLyog数据导入导出图文教程
Relationship between HTC mobile official solution, s-on/s-off and super CID
Redis集群搭建(基于6.x)
1205 Lock wait timeout exceeded; Try restarting transaction processing
Detailed explanation of redis6.x configuration parameters
vite 本地运行首次进入页面加载慢问题
Why does the debugger display the wrong function
win下搭建嵌入式开发环境及frp穿透
C# 迭代器的实现
Create a future and enjoy extraordinary | gbase Nantah General Motors unveiled opengauss Developer Day 2022
opengauss如何手工安装(非OM方式)