/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
/**
* Note: The returned array must be malloced, assume caller calls free().
*/
void Inorder(struct TreeNode* proot,int* parr,int* size)
{
if(proot==NULL)
return;
Inorder(proot->left,parr,size);
parr[(*size)++]=proot->val;
Inorder(proot->right,parr,size);
}
int* inorderTraversal(struct TreeNode* root, int* returnSize) {
int* arr=(int*)malloc(sizeof(int)*2000);
* returnSize=0;
Inorder(root,arr,returnSize);
return arr;
}
二叉树的中序遍历(力扣第94题)
最新推荐文章于 2024-09-14 18:52:56 发布