Leetcode—145. 二叉树的后序遍历【简单】

📅 发布时间:2026/7/4 18:07:15 👁️ 浏览次数:
Leetcode—145. 二叉树的后序遍历【简单】
2025每日刷题246Leetcode—145. 二叉树的后序遍历实现代码/** * Definition for a binary tree node. * type TreeNode struct { * Val int * Left *TreeNode * Right *TreeNode * } */funcpostorderTraversal(root*TreeNode)[]int{ans:make([]int,0)vardfsfunc(root*TreeNode)dfsfunc(root*TreeNode){ifrootnil{return}dfs(root.Left)dfs(root.Right)ansappend(ans,root.Val)}dfs(root)returnans}运行结果之后我会持续更新如果喜欢我的文章请记得一键三连哦点赞关注收藏你的每一个赞每一份关注每一次收藏都将是我前进路上的无限动力 ↖(▔▽▔)↗感谢支持