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

二叉树的中序遍历

https://www.nowcoder.com/practice/0bf071c135e64ee2a027783b80bf781d

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

全部评论

相关推荐

艾莉Alliy:拼多多好像很看重笔试,我秋招的时候笔试ak了,面试问了好多八股,全都说“不会”,照样全部通过了面试
点赞 评论 收藏
分享
ros275229:社团删了吧,cf因该1200才勉强入门吧,也删了,你可以写算法刷了多少道,都比这个好
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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