Binary Tree Inorder Traversal
来源:互联网 发布:有后台手机导航php源码 编辑:程序博客网 时间:2024/05/22 09:04
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Solution {public: vector<int> inorderTraversal(TreeNode *root) { vector<int> result; TreeNode* p=root; stack<TreeNode*> s; while(p!=NULL||!s.empty()) { if(p!=NULL) { s.push(p); p=p->left; } else { p=s.top(); result.push_back(p->val); s.pop(); p=p->right; } } return result; }};
0 0
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- 32个关键字9个控制语句34个运算符(C语言基础)
- winfrom 为datagridview 添加行号
- HELLO NEW PROGRAMMER'S LIFE
- 面向对象编程基础
- 列表–简介
- Binary Tree Inorder Traversal
- 块存储 对象存储 文件存储比较
- Optimizing MySQL queries on a single table
- sublime 常用插件
- 无法访问Word组件,failed due to the following error: 80070005 拒绝访问。
- LeetCode OJ Count Primes
- 关于HandlerThread
- abap金税下载EXCEL版
- JDBC-数据库的更新操作编程(三)