[Leetcode] Populating Next Right Pointers in Each Node
来源:互联网 发布:乡镇网络维护员工资 编辑:程序博客网 时间:2024/04/27 21:51
/** * 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) { // Start typing your C/C++ solution below // DO NOT write int main() function if (!root) return; if (!root->left || !root->right) return; TreeLinkNode* next = NULL; TreeLinkNode* p = root; while (p) { if (p->next) next = p->next->left; else next = NULL; p->left->next = p->right; p->right->next = next; p = p->next; } connect(root->left); }};
- 【LeetCode】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||
- LeetCode Populating Next Right Pointers in Each Node & Populating Next Right Pointers in Each Node I
- 【Leetcode】Populating Next Right Pointers in Each Node in JAVA
- LeetCode Populating Next Right Pointers in Each Node
- LeetCode Populating Next Right Pointers in Each Node II
- [Leetcode] Populating Next Right Pointers in Each Node
- LeetCode: Populating Next Right Pointers in Each Node
- [Leetcode] Populating Next Right Pointers in Each Node II
- [LeetCode] Populating Next Right Pointers in Each Node
- [LeetCode] Populating Next Right Pointers in Each Node II
- 【leetcode】 Populating Next Right Pointers in Each Node
- leetcode 78: Populating Next Right Pointers in Each Node
- leetcode 79: Populating Next Right Pointers in Each Node II
- Leetcode: Populating Next Right Pointers in Each Node
- [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
- JAVA路径问题大全
- Tiff转换Bitmap处理方法
- git 如何添加指定的文件提交.
- C#计算程序执行的时间间隔
- 【phpcms-v9】phpcms-v9系统搭建wap网站
- [Leetcode] Populating Next Right Pointers in Each Node
- yui笔记
- 高并发高流量网站架构
- 计算今天的凌晨时间
- 有关firefox不响应window.event的解决办法
- SVN更改登录用户
- VS与Win7共舞:系统服务的Session 0隔离
- 黑盒测试用例设计模式-正交试验(上)
- 杭电 ACM 1.2.5