void find(struct TreeNode* root, int* returnSize ,int* result)
{
if(root->left) find(root->left,returnSize,result);
result[(*returnSize)++]=root->val;
if(root->right) find(root->right,returnSize,result);
}
int* inorderTraversal(struct TreeNode* root, int* returnSize ) {
if(!root) return NULL;
int* result=malloc(sizeof(int)*1000);
*returnSize=0;
find(root,returnSize,result);
return result;
}

京公网安备 11010502036488号