leetcode 116: Populating Next Right Pointers in Each Node
来源:互联网 发布:网络彩票牌照 编辑:程序博客网 时间:2024/06/07 17:52
/** * 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) { vector<TreeLinkNode*> last; helper(root,0,last); } void helper(TreeLinkNode *root,int level,vector<TreeLinkNode*>& last) { if(!root) return; if(last.size()<=level) last.push_back(root); else { last[level]->next=root; last[level]=root; } helper(root->left,level+1,last); helper(root->right,level+1,last); }};
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
- S5PV210 Bootloader的问题
- Capitomcat配置
- POJ 3017 Cut the Sequence
- MyEclipse下搭建SSH框架 -----阿冬专栏
- 实现js的trim()方法
- leetcode 116: Populating Next Right Pointers in Each Node
- truncate table 之后id列的处理,重置ID列
- Hdu oj 1019 Least Common Multiple
- iOS开发问题——UITextField弹出PickerView方法
- MethodInvoker和Invoker
- IPhone上应用及数据所在的目录
- 关于PDF转换成TXT转换器的运用
- mysql高可用之MHA(补充2)--邮件报警
- java.util.Date、java.sql.Date、java.sql.Time、java.sql.Timestamp区别和联系