Flatten Binary Tree to Linked List
来源:互联网 发布:cdma网络是什么意思 编辑:程序博客网 时间:2024/05/17 22:30
Given a binary tree, flatten it to a linked list in-place.
For example,
Given
1 / \ 2 5 / \ \ 3 4 6
The flattened tree should look like:
1
\
2
\
3
\
4
\
5
\
6
class Solution {public: void flatten(TreeNode* root) { if(!root) return ; if(root->left) //不要漏 {flatten(root->left); TreeNode *p=root->left,*q=root->left; while(p->right) p=p->right; p->right=root->right; root->right=q; root->left=NULL;} flatten(root->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
- Windows下Nginx+Tomcat整合的安装与配置
- 51nod-1337:翻转游戏
- muduo中TcpConnection里IO事件的处理
- amoeba读写分离
- 最长公共子串问题
- Flatten Binary Tree to Linked List
- centos7 mysql5.7 相关
- 类加载双亲委派模型
- FFmpeg学习笔记
- Windows 剪切板的应用——复制浏览器or本地目录图片
- Problem--231A--Codeforces--Team
- vuejs2.0运用原生js实现简单的拖拽元素功能
- jsp中设置js的setTimeout()不管用??
- CSS3 Transform