当前位置:网站首页>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);
}
}
}边栏推荐
- 2022 simulated examination question bank and online simulated examination of tea master (primary) examination questions
- 【obs】win-capture需要winrt
- LeetCode 40:组合总和 II
- Jenkins remote build project timeout problem
- Why should we understand the trend of spot gold?
- Solution: could not find kf5 (missing: coreaddons dbusaddons doctools xmlgui)
- 芯片资料 网站 易特创芯
- Tianqing sends instructions to bypass the secondary verification
- 探索干货篇!Apifox 建设思路
- Ansible
猜你喜欢

快速使用 Jacoco 代码覆盖率统计

【webrtc】m98 screen和window采集

2022 simulated examination question bank and online simulated examination of tea master (primary) examination questions
![[2022 ciscn] replay of preliminary web topics](/img/1c/4297379fccde28f76ebe04d085c5a4.png)
[2022 ciscn] replay of preliminary web topics
![[SUCTF 2019]Game](/img/9c/362117a4bf3a1435ececa288112dfc.png)
[SUCTF 2019]Game

3D reconstruction - stereo correction

php导出百万数据

buuctf misc USB

LeetCode 40:组合总和 II

Codeforces Global Round 19
随机推荐
242. Bipartite graph determination
Open source ecosystem | create a vibrant open source community and jointly build a new open source ecosystem!
vus. Precautions for SSR requesting data in asyndata function
The principle and implementation of buffer playback of large video files
Live broadcast platform source code, foldable menu bar
2022 simulated examination question bank and online simulated examination of tea master (primary) examination questions
为什么要了解现货黄金走势?
Solution: could not find kf5 (missing: coreaddons dbusaddons doctools xmlgui)
解决:Could NOT find KF5 (missing: CoreAddons DBusAddons DocTools XmlGui)
[Stanford Jiwang cs144 project] lab3: tcpsender
Shell 脚本的替换功能实现
Technology cloud report: from robot to Cobot, human-computer integration is creating an era
Regular e-commerce problems part1
【数学笔记】弧度
Leetcode 43 String multiplication (2022.02.12)
C语言队列
vus.SSR在asynData函数中请求数据的注意事项
测试周期被压缩?教你9个方法去应对
2022年茶艺师(中级)考试试题及模拟考试
2022焊工(初级)判断题及在线模拟考试