class Solution { public: vector<int> inorderTraversal(TreeNode *root) { vector<int> res; stack<TreeNode *> s; TreeNode * p = root; while(p!=NULL||!s.empty()) { while(p!=NULL) { s.push(p); p = p->left; } p = s.top(); res.push_back(p->val); s.pop(); p = p->right; } return res; } };
leetcode:Binary Tree Inorder Traversal
原文地址:http://blog.csdn.net/majing19921103/article/details/44833963