void inorder(struct TreeNode* root, int* returnSize, int* a)
{
if (root == NULL)
{
return;
}
if (root != NULL)
{
inorder(root->left, returnSize, a);
a[*returnSize] = root->val;
(*returnSize)++;
inorder(root->right, returnSize, a);
}
}
int* inorderTraversal(struct TreeNode* root, int* returnSize)
{
int* a = malloc(100 * sizeof(int));
*returnSize = 0;
inorder(root, returnSize, a);
return a;
}
94. 二叉树的中序遍历
于 2021-11-19 15:22:26 首次发布