[LintCode] Flatten Binary Tree to Linked List 将二叉树展开成链表
Posted Grandyang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[LintCode] Flatten Binary Tree to Linked List 将二叉树展开成链表相关的知识,希望对你有一定的参考价值。
Flatten a binary tree to a fake "linked list" in pre-order traversal.
Here we use the right pointer in TreeNode as the next pointer in ListNode.
Notice
Don‘t forget to mark the left child of each node to null. Or you will get Time Limit Exceeded or Memory Limit Exceeded.
Example
1
1 2
/ \ 2 5 => 3
/ \ \ 3 4 6 4
5
6
以上是关于[LintCode] Flatten Binary Tree to Linked List 将二叉树展开成链表的主要内容,如果未能解决你的问题,请参考以下文章
[LintCode] Flatten Binary Tree to Linked List 将二叉树展开成链表
Lintcode22 Flatten List solution 题解
Flatten Binary Tree to Linked List