[LeetCode OJ]Binary Tree Postorder Traversal
来源:互联网 发布:什么是多维数据分析 编辑:程序博客网 时间:2024/06/08 06:20
Given a binary tree, return the postorder traversal of its nodes' values.
1
\
2
/
For example:
Given binary tree {1,#,2,3},1
\
2
/
3
return [3,2,1].顺序容器还真是比较方便的,有了前面的中序和前序的基础,这个很简单。
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: void inorder(TreeNode *root, vector<int> &v) { if(root == NULL) return ; inorder(root->left, v); inorder(root->right, v); v.push_back(root->val); } vector<int> postorderTraversal(TreeNode *root) { vector<int> v; inorder(root, v); return v; }};
0 0
- LeetCode OJ:Binary Tree Postorder Traversal
- LeetCode OJ: Binary Tree Postorder Traversal
- LeetCode OJ - Binary Tree Postorder Traversal
- [LeetCode OJ]Binary Tree Postorder Traversal
- LeetCode OJ Binary Tree Postorder Traversal
- LeetCode OJ:Construct Binary Tree from Inorder and Postorder Traversal
- LeetCode OJ --问题与解答 Binary Tree Postorder Traversal
- leetcode OJ -Binary Tree Postorder Traversal(2014.1.20)
- [LeetCode OJ] Binary Tree Postorder Traversal 解题报告
- LeetCode OJ Construct Binary Tree from Inorder and Postorder Traversal
- LeetCode Binary Tree Postorder Traversal
- LeetCode:Binary Tree Postorder Traversal
- Leetcode: Binary Tree Postorder Traversal
- Leetcode: Binary Tree Postorder Traversal
- LeetCode:Binary Tree Postorder Traversal
- Leetcode Binary Tree Postorder Traversal
- [LeetCode]Binary Tree Postorder Traversal
- [LeetCode] Binary Tree Postorder Traversal
- CodeForces - 483B Friends and Presents
- 双端队列
- composer之创建自己的包
- 慎用Kill -9 来杀死进程
- 菜鸟要做架构师(一)——如何快速开发中小型系统
- [LeetCode OJ]Binary Tree Postorder Traversal
- D3D11_INPUT_ELEMENT_DESC,D3D11_BUFFER_DESC,ID3D11InputLayout,ID3D11PixelShader,ID3D11VertexShader
- JSONKit 解析逗号冗余的json字符串失败
- android基础 Service 实现代码
- 求对称字符串的最大长度算法
- javaweb-servlet-request方法
- 带自加加这一类常会出现的错误
- 软件开发1
- Sqlite使用