首页 > 其他 > 详细

[LintCode] Flatten Binary Tree to Linked List 将二叉树展开成链表

时间:2016-07-05 01:01:53      阅读:266      评论:0      收藏:0      [点我收藏+]

 

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 将二叉树展开成链表

原文:http://www.cnblogs.com/grandyang/p/5642095.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!