当前位置:网站首页>Leetcode skimming: binary tree 02 (middle order traversal of binary tree)
Leetcode skimming: binary tree 02 (middle order traversal of binary tree)
2022-07-02 00:26:00 【Taotao can't learn English】
94. Middle order traversal of binary trees
package com.programmercarl.tree;
import java.util.ArrayList;
import java.util.List;
/** * @ClassName InorderTraversal * @Descriotion TODO * @Author nitaotao * @Date 2022/7/1 15:32 * @Version 1.0 * https://leetcode.cn/problems/binary-tree-inorder-traversal/ * 94. Middle order traversal of binary trees **/
public class InorderTraversal {
public List<Integer> inorderTraversal(TreeNode root) {
List<Integer> result = new ArrayList<Integer>();
traversal(root, result);
return result;
}
/** * In the sequence traversal * @param root * @param result */
public void traversal(TreeNode root, List<Integer> result) {
if(root==null) {
return;
}
// Left middle right
traversal(root.left, result);
result.add(root.val);
traversal(root.right, result);
}
}
边栏推荐
- 【CTF】bjdctf_ 2020_ babystack2
- 股票开户哪个证券公司比较安全
- LDR6035智能蓝牙音响可对手机设备持续充放电方案
- EMC circuit protection device for surge and impulse current protection
- SQL数据分析之窗口排序函数rank、dense_rank、raw_number与lag、lead窗口偏移函数【用法整理】
- 微信小程序缓存过期时间的相关设置(推荐)
- 【QT】测试Qt是否能连接上数据库
- Ldr6035 smart Bluetooth audio can be charged and released (5.9.12.15.20v) fast charging and fast releasing device charging
- Use the htaccess file to prohibit the script execution permission in the directory
- leetcode96不同的二叉搜索树
猜你喜欢
B tree and b+tree of MySQL
2023款雷克萨斯ES产品公布,这回进步很有感
【QT】对于Qt MSVC 2017无法编译的问题解决
Graduation season | Huawei experts teach the interview secret: how to get a high paying offer from a large factory?
Digital transformation has a long way to go, so how to take the key first step
起床困难综合症(按位贪心)
Intelligent operation and maintenance practice: banking business process and single transaction tracking
Use es to realize epidemic map or take out order function (including code and data)
Asp .NetCore 微信订阅号自动回复之文本篇
mysql之B tree 以及 B+tree
随机推荐
Relatively easy to understand PID understanding
在证券账户上买基金安全吗?哪里可以买基金
Record the accidental success and failure of uploading large files
Is it safe to buy funds in a securities account? Where can I buy funds
Download the online video m3u8 tutorial
[QT] QT cannot find a solution to the compiler using msvc2017
Correlation - intra group correlation coefficient
[QT] qtcreator uninstall and installation (abnormal state)
[cmake] cmake configuration in QT Creator
基于全志H3的QT5.12.9移植教程
13 MySQL constraint
北京炒股开户选择手机办理安全吗?
Take the enclave Park as a sample to see how Yuhua and Shaoshan play the song of Chang Zhu Tan integrated development
LDR6035智能蓝牙音响可充可放(5.9.12.15.20V)快充快放设备充电
Operate database transactions with jpatractionmanager
启牛学院开户安全的吗?开户怎么开?
JS——图片转base码 、base转File对象
使用 ES 实现疫情地图或者外卖点餐功能(含代码及数据)
What does open loop and closed loop mean?
Leetcode96 different binary search trees