当前位置:网站首页>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);
}
}

边栏推荐
- How to turn off the boot auto start software in win11
- 2022年高处安装、维护、拆除考题模拟考试平台操作
- On the next generation entrance of the metauniverse -- the implementation of brain computer interface
- Hls4ml reports an error the board_ part definition was not found for tul. com. tw:pynq-z2:part0:1.0.
- 300 linear algebra Lecture 4 linear equations
- Exclusive news: Alibaba cloud quietly launched RPA cloud computer and has opened cooperation with many RPA manufacturers
- 2022熔化焊接与热切割上岗证题目模拟考试平台操作
- Interesting! Database is also serverless!
- 2022安全员-A证考题及在线模拟考试
- 人脸识别系统 —— OpenCV人脸检测
猜你喜欢

uniapp使用腾讯地图选点 没有window监听回传用户的位置信息,怎么处理

Big factories are wolves, small factories are dogs?

Detailed explanation and code example of affinity propagation clustering calculation formula based on graph

How to create a pyramid with openmesh

【多线程】 实现单例模式 ( 饿汉、懒汉 ) 实现线程安全的单例模式 (双重效验锁)

300 linear algebra Lecture 4 linear equations

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

大厂做狼,小厂做狗?

Myslq ten kinds of locks, an article will take you to fully analyze

Items in richview documents
随机推荐
fastDFS入门
EDA工具对芯片产业的重要性知识科普
人脸识别系统 —— OpenCV人脸检测
Myslq ten kinds of locks, an article will take you to fully analyze
Importance of EDA tools to chip industry knowledge popularization
C # joint Halcon application - Dahua camera acquisition class
利用QEventLoop实现同步等待槽函数返回
2022年高处安装、维护、拆除考题模拟考试平台操作
Review notes of Zhang Haifan in introduction to software engineering (Sixth Edition)
RichView TRVDocParameters 页面参数设置
Keras machine translation practice
math_ Use differentiation to calculate approximate value
渗透工具-TrustedSec 公司的渗透测试框架 (PTF)
Optimization of the problem that the request flow fails to terminate during page switching of easycvr cluster video Plaza
Customize the insertion of page labels and realize the initial search of similar address books
宅男壁纸大全微信小程序源码-带动态壁纸支持多种流量主
RichView 文档中的 ITEM
internship:逐渐迈向项目开发
Principle of motion capture system
