Populating Next Right Pointers in Each Node II
来源:互联网 发布:失败 无助 知乎 编辑:程序博客网 时间:2024/05/24 04:57
/** * Definition for binary tree with next pointer. * struct TreeLinkNode { * int val; * TreeLinkNode *left, *right, *next; * TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(NULL) {} * }; */class Solution {public: void connect(TreeLinkNode *root) { if(root == NULL) return; queue<TreeLinkNode*> q; q.push(root); q.push(NULL); while(q.size() > 1) { TreeLinkNode* t = q.front(); q.pop(); if(t == NULL) { q.push(NULL); continue; } t->next = q.front(); if(t->left) q.push(t->left); if(t->right) q.push(t->right); } }};
0 0
- Populating Next Right Pointers in Each Node、Populating Next Right Pointers in Each Node II
- 【LeetCode】Populating Next Right Pointers in Each Node Populating Next Right Pointers in Each Node II
- LeetCode Populating Next Right Pointers in Each Node II
- [Leetcode] Populating Next Right Pointers in Each Node II
- [LeetCode] Populating Next Right Pointers in Each Node II
- leetcode 79: Populating Next Right Pointers in Each Node II
- [Leetcode] Populating Next Right Pointers in Each Node ii
- leetcode Populating Next Right Pointers in Each Node II
- 【leetcode】Populating Next Right Pointers in Each Node II
- Populating Next Right Pointers in Each Node II
- Populating Next Right Pointers in Each Node II
- Populating Next Right Pointers in Each Node II
- Populating Next Right Pointers in Each Node II
- Populating Next Right Pointers in Each Node II
- [Leetcode]Populating Next Right Pointers in Each Node II
- Populating Next Right Pointers in Each Node II
- Populating Next Right Pointers in Each Node (I & II)
- Populating Next Right Pointers in Each Node II
- git 学习笔记4-git提交代码
- wordpress主题制作之文章置顶
- Nirvana now!连载1
- HDOJ 1229 还是A+B
- Material Design之CoordinatorLayout+AppBarLayout实现上滑隐藏ToolBar
- Populating Next Right Pointers in Each Node II
- json java/ javascript
- JavaBean
- PAT 数据结构 04-树5. File Transfer (25)
- Git tag 操作
- 使用libxml解析HTML -- Hpple
- vb.net Datagridview 下拉框应用
- Sublime Text2解决中文乱码
- DHTMLXTree的使用