标签:
/** * 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> v; if(root==NULL) return v; if(root->left==NULL && root->right==NULL) { v.push_back(root->val); return v; } if(root->left) v=inorderTraversal(root->left); v.push_back(root->val); if(root->right){ vector<int> vv; vv=inorderTraversal(root->right); for(int i=0;i<vv.size();i++){ v.push_back(vv[i]); } } return v; } };
标签:
原文地址:http://www.cnblogs.com/julie-yang/p/4688138.html