void inorder(TreeNode* root, vector<int>& res) {
时间: 2024-06-01 12:09:41 浏览: 163
&res) {
if(root == NULL) return;
inorder(root -> left, res);
res.push_back(root -> val);
inorder(root -> right, res);
}
vector<int> inorderTraversal(TreeNode* root) {
vector<int> res;
inorder(root, res);
return res;
}
阅读全文