二叉树遍历94. Binary Tree Inorder Traversal
来源:互联网 发布:hdfs数据删除如何恢复 编辑:程序博客网 时间:2024/04/30 10:35
/** * Definition for a binary tree node. * 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> ans; stack<TreeNode* > nodeStack; TreeNode* current = root; if (root == NULL) return ans; while (nodeStack.size() || current != NULL) { while (current != NULL) { nodeStack.push(current); current = current->left; } if (!nodeStack.empty()) { current = nodeStack.top(); nodeStack.pop(); ans.push_back(current->val); current = current->right; } } return ans; }};
0 0
- 二叉树遍历94. Binary Tree Inorder Traversal
- 【二叉树中序遍历】Binary Tree Inorder Traversal
- 94.Binary Tree Inorder Traversal(二叉树先序遍历)
- [leetcode-二叉树中序遍历]--94. Binary Tree Inorder Traversal
- 二叉树中序遍历——94. Binary Tree Inorder Traversal
- leetcode 94. Binary Tree Inorder Traversal 二叉树中序递归遍历
- LeetCode Binary Tree Inorder Traversal 中序遍历二叉树
- Binary Tree Inorder Traversal 二叉树的中序遍历
- 二叉树的中序遍历 Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal 二叉树的中序遍历
- 94.LeetCode Binary Tree Inorder Traversal(medium)[中序遍历二叉树 树的遍历]
- LeetCode 94. Binary Tree Inorder Traversal(二叉树的中序遍历)
- 94. Binary Tree Inorder Traversal(中序遍历二叉树)
- [LeetCode]94. Binary Tree Inorder Traversal--二叉树的中序遍历
- 【二叉树经典问题】94. Binary Tree Inorder Traversal
- 【LeetCode】Binary Tree Inorder Traversal ---二叉树中序遍历
- Binary Tree Inorder Traversal 二叉树中序遍历@LeetCode
- Leetcode: Binary Tree Inorder Traversal(二叉树中序遍历)
- torch入门笔记20:torch实现freeze layer的操作
- UIView的简单动画
- Codeforces 516B Drazil and Tiles【类拓扑排序】好题!
- Linux下oracle数据库启动和关闭操作
- Idea利用Git提交代码到github步骤
- 二叉树遍历94. Binary Tree Inorder Traversal
- JAVA多线程和并发基础面试问答(转载)
- 136. Single Number
- 二叉树遍历144. Binary Tree Preorder Traversal
- myisam和innodb的区别
- 数据库的原理
- HDU 5072Coprime
- 冒泡排序
- 计算机网路(四)使用广播信道的以太网