void postorder(struct TreeNode* root, int* returnSize, int* a)
{
if (root == NULL)
{
return;
}
if (root != NULL)
{
postorder(root->left, returnSize, a);
postorder(root->right, returnSize, a);
a[*returnSize] = root->val;
(*returnSize)++;
}
}
int* postorderTraversal(struct TreeNode* root, int* returnSize)
{
int* a = malloc(100 * sizeof(int));
*returnSize = 0;
postorder(root, returnSize, a);
return a;
}
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交