void InOrder(struct TreeNode* root,int *nums,int* returnSize)
{
if(root==NULL) return;
InOrder(root->left,nums,returnSize);
nums[(*returnSize)++]=root->val;
InOrder(root->right,nums,returnSize);
}
int* inorderTraversal(struct TreeNode* root, int* returnSize) {
int* nums=(int*)malloc(101*sizeof(int));
*returnSize=0;
InOrder(root,nums,returnSize);
return nums;
}
二叉树的中序遍历(力扣)
最新推荐文章于 2024-07-07 13:48:02 发布