LeetCode 114 Flatten Binary Tree to Linked List
来源:互联网 发布:喜马拉雅英语软件下载 编辑:程序博客网 时间:2024/05/19 17:57
题目描述
Given a binary tree, flatten it to a linked list in-place.
For example,
Given
The flattened tree should look like:
代码
TreeNode prev; void preorder(TreeNode root) { if (root == null) return; TreeNode left = root.left; TreeNode right = root.right; // root if (prev != null) { prev.right = root; prev.left = null; } prev = root; preorder(left); preorder(right); } public void flatten(TreeNode root) { prev = null; preorder(root); }
1 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
- [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
- 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
- [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
- LeetCode:Flatten Binary Tree to Linked List
- [LeetCode] Flatten Binary Tree to Linked List
- Linux tar命令
- Tomcat集群配置学习篇-----分布式应用
- CSS常见错误集锦(1)-关于外部样式表中background-image:url()的设置
- ns2安装802.11p补丁包
- pycharm快捷键及一些常用设置
- LeetCode 114 Flatten Binary Tree to Linked List
- delphi的颜色及其效果
- ubuntu 12.04 无法连接无线网络驱动问题解决
- 敏捷开发之Scrum扫盲篇
- 支持向量机SVM(五)SMO算法
- Effective Java笔记之改写equals的通用约定
- OC与Swift调用函数方法格式对比
- PRVF-0002 : 无法检索本地节点名
- 用jPlayer实现网页在线视频播放