当前位置:网站首页>Force buckle 145 Binary Tree Postorder Traversal
Force buckle 145 Binary Tree Postorder Traversal
2022-07-07 07:55:00 【Yangshiwei....】
subject :
analysis :
After the sequence traversal , First left node , Rear right node , Finally, its own node , The difference between the first, middle and last traversals is the difference in order , Just exchange the code and position
Code :
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode() {}
* TreeNode(int val) { this.val = val; }
* TreeNode(int val, TreeNode left, TreeNode right) {
* this.val = val;
* this.left = left;
* this.right = right;
* }
* }
*/
class Solution {
public List<Integer> postorderTraversal(TreeNode root) {
List<Integer> list =new ArrayList();
last(root,list);
return list;
}
public void last(TreeNode node,List<Integer> list){
if(node!=null){
if(node.left!=null){
last(node.left,list);
}if(node.right!=null){
last(node.right,list);
}
list.add(node.val);
}
}
}
边栏推荐
- Shell 脚本的替换功能实现
- Linux server development, SQL statements, indexes, views, stored procedures, triggers
- 【VHDL 并行语句执行】
- Qt学习27 应用程序中的主窗口
- Idea add class annotation template and method template
- 242. Bipartite graph determination
- [experience sharing] how to expand the cloud service icon for Visio
- Use and analysis of dot function in numpy
- JS get all date or time stamps between two time stamps
- C语言航班订票系统
猜你喜欢
MySQL multi column index (composite index) features and usage scenarios
Leetcode 90: subset II
[guess-ctf2019] fake compressed packets
Asemi rectifier bridge rs210 parameters, rs210 specifications, rs210 package
You Li takes you to talk about C language 6 (common keywords)
Most elements
即刻报名|飞桨黑客马拉松第三期等你挑战
探索Cassandra的去中心化分布式架构
[UTCTF2020]file header
2022年茶艺师(中级)考试试题及模拟考试
随机推荐
Figure out the working principle of gpt3
[UVM practice] Chapter 1: configuring the UVM environment (taking VCs as an example), run through the examples in the book
pytest+allure+jenkins環境--填坑完畢
padavan手动安装php
面试结束后,被面试官在朋友圈吐槽了......
Route jump in wechat applet
C语言航班订票系统
misc ez_usb
Cnopendata list data of Chinese colleges and Universities
Codeforces Global Round 19
[OBS] win capture requires winrt
Common method signatures and meanings of Iterable, collection and list
2022 simulated examination question bank and online simulated examination of tea master (primary) examination questions
pytest+allure+jenkins安装问题:pytest: error: unrecognized arguments: --alluredir
Solve could not find or load the QT platform plugin "xcb" in "
【斯坦福计网CS144项目】Lab3: TCPSender
[UVM foundation] what is transaction
微信小程序基本组件使用介绍
misc ez_ usb
vus. Precautions for SSR requesting data in asyndata function