题解 | #二叉树的后序遍历#

二叉树的后序遍历

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;
}

全部评论

相关推荐

Yki_:你要算时间成本呀,研究生两三年,博士三四年,加起来就五六年了,如果你本科去腾讯干五年,多领五年的年薪,加上公司内涨薪,可能到时候十五年总薪资也跟博士差不多
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-09 12:05
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务