/** * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ class Solution { public: /** * * @param root TreeNode类 the root of binary tree * @return int整型vector<vector<>> */ void traversal(TreeNode* root, vector<vector<int>>& res){ if(!root) return; res[0].push_back(root->val); traversal(root->left, res); res[1].push_back(root->val); traversal(root->right, res); res[2].push_back(root->val); } vector<vector<int> > threeOrders(TreeNode* root) { // write code here vector<vector<int>> res{{}, {}, {}}; traversal(root, res); return res; } };