题解 | #二叉树的中序遍历#
二叉树的中序遍历
http://www.nowcoder.com/practice/0bf071c135e64ee2a027783b80bf781d
用递归实现中序遍历并存入vector中 void InOrder(TreeNode* root,vector<int>& a) { int i=0; if(root) { InOrder(root->left,a); a.push_back(root->val); InOrder(root->right,a); } } class Solution { public: vector<int> inorderTraversal(TreeNode* root) { vector<int> a; InOrder(root,a); return a; } };