当前位置:网站首页>leetcode刷题:二叉树03(二叉树的后序遍历)
leetcode刷题:二叉树03(二叉树的后序遍历)
2022-07-01 19:16:00 【涛涛英语学不进去】
145.二叉树的后序遍历
package com.programmercarl.tree;
import java.util.ArrayList;
import java.util.List;
/** * @ClassName PostorderTraversal * @Descriotion TODO * @Author nitaotao * @Date 2022/7/1 15:27 * @Version 1.0 * 145. 二叉树的后序遍历 * https://leetcode.cn/problems/binary-tree-postorder-traversal/ **/
public class PostorderTraversal {
public List<Integer> postorderTraversal(TreeNode root) {
List<Integer> result = new ArrayList<Integer>();
traversal(root, result);
return result;
}
/** * 后序遍历 * @param root * @param result */
public void traversal(TreeNode root, List<Integer> result) {
//确定终止条件
if (root == null) {
return;
}
//左
traversal(root.left,result);
//右
traversal(root.right,result);
//中
result.add(root.val);
}
}

边栏推荐
- Customize the insertion of page labels and realize the initial search of similar address books
- C # joint halcon Application - Dahua Camera Collection class
- EDA工具对芯片产业的重要性知识科普
- Richview trvdocparameters page parameter settings
- 王者战力查询改名工具箱小程序源码-带流量主激励广告
- 利用QEventLoop实现同步等待槽函数返回
- Use Zadig to build a continuous delivery platform from 0 to 1
- Entering Ruxin Town, digital intelligence transformation connects "future community"
- 300题线性代数 第四讲 线性方程组
- [multithreading] lock strategy
猜你喜欢

2022熔化焊接与热切割上岗证题目模拟考试平台操作

How to connect the two nodes of the flow chart

Review notes of Zhang Haifan in introduction to software engineering (Sixth Edition)

Test of NSI script

fastDFS入门

小鸟逃票登机,如何反思,应如何解决,飞机为何怕小鸟?

Exclusive news: Alibaba cloud quietly launched RPA cloud computer and has opened cooperation with many RPA manufacturers

cocoaPods 添加成功后,导入不了头文件或者not found file 报错

1592 example 1 King (sgu223 loj10170 luogu1896 increase + / provincial election -) violent thinking pressure DP 01 Backpack

Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
随机推荐
关于new Set( )还有哪些是你不知道的
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
Arduino Stepper库驱动28BYJ-48步进电机测试程序
新版Free手机、PC、平板、笔记本四端网站缩略展示图在线一键生成网站源码
300题线性代数 第四讲 线性方程组
What did you learn about cheating after you went to college?
强大的万年历微信小程序源码-支持多做流量主模式
牛客编程题--必刷101之字符串(高效刷题,举一反三)
《軟件工程導論(第六版)》 張海藩 複習筆記
Past and present life of product modular design
Test of NSI script
STC 32位8051单片机开发实例教程 三 程序编译设置与下载
升级版手机检测微信工具小程序源码-支持多种流量主模式
[multithreading] realize the singleton mode (hungry and lazy) realize the thread safe singleton mode (double validation lock)
走进如心小镇,数智化变革连接“未来社区”
Summary of SQL aggregate query method for yyds dry goods inventory
新牛牛盲盒微信小程序源码_支持流量变现,带完整素材图片
RichView 文档中的 ITEM
三菱PLC FX3U脉冲轴点动功能块(MC_Jog)
Is it safe to open an account online? Can a novice open a stock trading account.
