当前位置:网站首页>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);
}
}
边栏推荐
- Which app is better and more secure for stock mobile account opening
- JS——图片转base码 、base转File对象
- Jielizhi Bluetooth headset quality control and production skills [chapter]
- Review data desensitization system
- Node -- egg creates a local file access interface
- UVM tutorial
- [QT] test whether QT can connect to the database
- An intern's journey to cnosdb
- Vue force cleaning browser cache
- 【模板】自适应辛普森积分
猜你喜欢
Linux centos7 installation Oracle11g super perfect novice tutorial
Export default the exported object cannot be deconstructed, and module Differences between exports
LeetCode中等题题分享(5)
LDR6035智能蓝牙音响可对手机设备持续充放电方案
2022 pinduoduo details / pinduoduo product details / pinduoduo SKU details
2023款雷克萨斯ES产品公布,这回进步很有感
Ldr6035 smart Bluetooth audio can continuously charge and discharge mobile devices
Flow control statement of SQL data analysis [if, case... When detailed]
2022拼多多详情/拼多多商品详情/拼多多sku详情
时间复杂度与空间复杂度
随机推荐
Is it safe to choose mobile phone for stock trading account opening in Beijing?
What is ThreadLocal memory leak and how to solve it
【opencv】train&test HOG+SVM
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
Digital transformation has a long way to go, so how to take the key first step
Regular expression collection
Download the online video m3u8 tutorial
When installing mysql, there are two packages: Perl (data:: dumper) and Perl (JSON)
在证券账户上买基金安全吗?哪里可以买基金
Shell custom function
The new version of graphic network PDF will be released soon
Openvino model performance evaluation tool DL workbench
时间复杂度与空间复杂度
Difficult to get up syndrome (bit by bit greed)
Jielizhi Bluetooth headset quality control and production skills [chapter]
【CTF】bjdctf_2020_babystack2
牛客-练习赛101-推理小丑
Jielizhi, production line assembly link [chapter]
Is it safe for qiniu college to open an account? How to open an account?
Node——Egg 创建本地文件访问接口