题解 | #二叉树的后序遍历#
二叉树的后序遍历
https://www.nowcoder.com/practice/1291064f4d5d4bdeaefbf0dd47d78541
int result[100];
int* postorderTraversal(struct TreeNode* root, int* returnSize ) ;
void find(struct TreeNode* root, int* returnSize,int* result)
{
if(root->left) find(root->left, returnSize,result);
if(root->right) find(root->right, returnSize,result);
result[(*returnSize)++]=root->val;
}
int* postorderTraversal(struct TreeNode* root, int* returnSize ) {
// write code here
*returnSize=0;
if(!root) return returnSize;
find(root,returnSize,result);
return result;
}
查看3道真题和解析