LeetCode(116) Populating Next Right Pointers in Each Node
来源:互联网 发布:我国历年gdp数据 编辑:程序博客网 时间:2024/05/17 23:32
深度优先搜索
/** * 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; if(root->left == NULL) return; if(root->next == NULL) { root->left->next = root->right; root->right->next = NULL; } if(root->next != NULL) { root->left->next = root->right; root->right->next = root->next->left; } connect(root->left); connect(root->right); }};
0 0
- LeetCode 116: Populating Next Right Pointers in Each Node
- LeetCode 116 Populating Next Right Pointers in Each Node
- LeetCode: Populating Next Right Pointers in Each Node [116]
- LeetCode(116) Populating Next Right Pointers in Each Node
- [leetcode 116] Populating Next Right Pointers in Each Node
- leetcode || 116、Populating Next Right Pointers in Each Node
- Populating Next Right Pointers in Each Node - LeetCode 116
- LeetCode 116 Populating Next Right Pointers in Each Node
- leetcode-116-Populating Next Right Pointers in Each Node
- [Leetcode 116, Medium] Populating Next Right Pointers in Each Node
- leetcode[116]:Populating Next Right Pointers in Each Node
- LeetCode(116) Populating Next Right Pointers in Each Node
- Leetcode #116 Populating Next Right Pointers in Each Node
- [leetcode-116]Populating Next Right Pointers in Each Node(c++)
- [leetcode-116]Populating Next Right Pointers in Each Node(c++)
- leetcode 116: Populating Next Right Pointers in Each Node
- LeetCode(116) Populating Next Right Pointers in Each Node
- LeetCode 116: Populating Next Right Pointers in Each Node
- 《Objective-C基础教程》第四章 继承
- poj1753 Flip Game DFS,枚举
- Best Time to Buy and Sell Stock II
- [Learning Linux For Fun] unit 1 1.2~1.3
- leetcode_Median of Two Sorted Arrays
- LeetCode(116) Populating Next Right Pointers in Each Node
- 智慧城市
- UE4 移动平台游戏开发
- iOS 9之分屏多任务(Split View)
- POJ 1511 SPFA 模板
- C++对象模型——对象成员的效率 (Object Member Efficiency)(第三章)
- cocos2d-x 2.0版本 自适应屏幕分辨率
- poj 1035 Spell checker
- 深度学习(四)卷积神经网络入门学习(1)