Flatten Binary Tree to Linked List(inorder)

Given a binary tree, flatten it to a linked list in-place.

For example, given the following tree:

    1
   / \
  2   5
 / \   \
3   4   6

The flattened tree should look like:

1
 \
  2
   \
    3
     \
      4
       \
        5
         \
          6

分析

题目是preorder我做的是双链表Inorder

注意Inorder赋right时候,没有right才赋值,有的话别动!!!

Last updated

Was this helpful?