leetcode:Binary Tree Postorder Traversal
来源:互联网 发布:拍孕肚用什么软件 编辑:程序博客网 时间:2024/06/03 13:01
class Solution {public: vector<int> postorderTraversal(TreeNode *root) { vector<int> res; stack<pair<TreeNode *,int>>s; TreeNode *p = root; while(p!=NULL||!s.empty()) { while(p) { s.push(pair<TreeNode*,int>(p,1)); p = p->left; } pair<TreeNode*,int> q = s.top(); s.pop(); if(q.second==1) { s.push(pair<TreeNode*,int>(q.first,2)); p = q.first->right; } else { res.push_back(q.first->val); p = NULL; } } return res; }};
0 0
- 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
- leetcode Binary Tree Postorder Traversal
- 【LeetCode】Binary Tree Postorder Traversal
- LeetCode | Binary Tree Postorder Traversal
- Leetcode: Binary Tree Postorder Traversal
- Binary Tree Postorder Traversal - LeetCode
- LeetCode - Binary Tree Postorder Traversal
- [LeetCode]Binary Tree Postorder Traversal
- Binary Tree Postorder Traversal -- LeetCode
- [LeetCode]Binary Tree Postorder Traversal
- 【LeetCode】Binary Tree Postorder Traversal
- 手机内存卡数据恢复丢失删除文件如何恢复
- 二叉树前/中/后序遍历非递归实现(用栈实现)LeetCode Binary Tree Traversal
- 用QT实现同步调用WebService
- Odoo8.0的弹窗通过标题栏进行移动
- 数字和日期之间的相互转换
- leetcode:Binary Tree Postorder Traversal
- java问题集锦
- android开发中常用的Eclipse快捷键详细解析
- YUV422 to JPEG ---libjpeg 参考网页
- Best Time to Buy and Sell Stock - LeetCode
- perl 包和模块
- Java 异常处理及其应用
- 【OpenCV入门教程之十七】OpenCV重映射 & SURF特征点检测合辑
- JavaWeb-17 (JDBC编程进阶2)