Flatten Binary Tree to Linked List
来源:互联网 发布:海颐软件 编辑:程序博客网 时间:2024/06/11 05:43
Given a binary tree, flatten it to a linked list in-place.
For example,
Given
1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like:
1 \ 2 \ 3 \ 4 \ 5 \ 6
class Solution {public: TreeNode *node = NULL; void flatten(TreeNode *root) { if(root == NULL) return; if(node != NULL) { node->left = NULL; node->right = root; } node = root; TreeNode *left = root->left; TreeNode *right = root->right; flatten(left); flatten(right); }};
0 0
- LeetCode: Flatten Binary Tree to Linked List
- LeetCode Flatten Binary Tree to Linked List
- LeetCode: Flatten Binary Tree to Linked List
- [Leetcode] Flatten Binary Tree to Linked List
- Flatten Binary Tree to Linked List
- [LeetCode] Flatten Binary Tree to Linked List
- Leetcode: Flatten Binary Tree to Linked List
- leetcode Flatten Binary Tree to Linked List
- LeetCode Flatten Binary Tree to Linked List
- Flatten Binary Tree to Linked List
- Flatten Binary Tree to Linked List
- LeetCode - Flatten Binary Tree to Linked List
- 【leetcode】Flatten Binary Tree to Linked List
- Flatten Binary Tree to Linked List
- [LeetCode]Flatten Binary Tree to Linked List
- Flatten Binary Tree to Linked List
- Flatten Binary Tree to Linked List
- Flatten Binary Tree to Linked List
- 程序员解决问题的60个策略
- 松岗沙浦网站免费推广培训_近些年网络营销人才的稀缺涌现大量的高薪就业机会,来月亮湾培训学校让你不在为工作烦恼
- iOS开发笔记--iphone开发震动与播放声音Demo
- 程序员应该投资的10件事
- Python os模块
- Flatten Binary Tree to Linked List
- LINQ 之Union All/Union/Intersect操作
- ASP.Net页面刷新后自动滚动到原来位置
- xml模式(xml:Schema)实验
- Eclipse 操作
- SDWebImage使用,图片加载和缓存
- Android官方入门文档[15]重新创建一个Activity活动
- 生肖属相为什么从立春算起?
- UIColor的RGB转16进制和转UIImage