码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2016-07-05 01:04:15      阅读:195      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!