首页 > 其他 > 详细

Leetcode 117

时间:2019-02-06 11:05:24      阅读:194      评论:0      收藏:0      [点我收藏+]
if(root == NULL) return;
        queue<TreeLinkNode *> que;
        que.push(root);
        while(!empty(que)){
            int lens = que.size();
            for(int i=0;i < lens-1;i++){
                TreeLinkNode *temp = que.front();
                que.pop();
                temp->next = que.front();
                if(temp->left) que.push(temp->left);
                if(temp->right) que.push(temp->right);
            }
            TreeLinkNode *temp2 = que.front();
            temp2->next = NULL;
            que.pop();
            if(temp2->left) que.push(temp2->left);
            if(temp2->right) que.push(temp2->right);
        }

_

Leetcode 117

原文:https://www.cnblogs.com/cunyusup/p/10353522.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!