[LeetCode] Populating Next Right Pointers in Each Node II
来源:互联网 发布:中国阳江网络问政平台 编辑:程序博客网 时间:2024/06/06 23:15
题目链接
void connect2(TreeLinkNode *root) {TreeLinkNode* level_head = root;while(level_head != NULL){TreeLinkNode* next_level_head = NULL;bool get_next_head = false;TreeLinkNode* cur_node = level_head;vector<TreeLinkNode*> two_nodes;while(cur_node != NULL){if(cur_node->left != NULL){if(!get_next_head){next_level_head = cur_node->left;get_next_head = true;}two_nodes.push_back(cur_node->left);if(two_nodes.size() == 2){two_nodes[0]->next = two_nodes[1];two_nodes.erase(two_nodes.begin());}}if(cur_node->right != NULL){if(!get_next_head){next_level_head = cur_node->right;get_next_head = true;} two_nodes.push_back(cur_node->right);if(two_nodes.size() == 2){two_nodes[0]->next = two_nodes[1];two_nodes.erase(two_nodes.begin());}}cur_node = cur_node->next;}level_head = next_level_head;} }
0 0
- 【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
- [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 - 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]Populating Next Right Pointers in Each Node II
- 【LeetCode OJ】Populating Next Right Pointers in Each Node II
- [LeetCode] Populating Next Right Pointers in Each Node II
- ubuntu下intel tune amplifier的设置
- IE下表单提交存入数据库乱码
- 什么是IIS连接数限制 和如何修改iis连接数
- VS2005创建智能设备项目失败
- SVN 更新时忽略指定文件或目录
- [LeetCode] Populating Next Right Pointers in Each Node II
- Quartz 在Java Web Application中使用
- 【面试题一】Unity3D协同程序的学习理解与说明
- deep learning in NLP
- xen-3.3.0
- apache2.2 虚拟主机配置
- JW Player 使用 RTMP 流
- Directx 计算着色器(compute shader)
- 应该你跟执法人员