LeetCode 114. Flatten Binary Tree to Linked List
题目描述:
Given a binary tree, flatten it to a linked list in-place.
For example, Given
1
2
3
4
5
6 1
/ \
2 5
/ \ \
3 4 6The flattened tree should look like:
1
2
3
4
5
6
7
8
9
10
11 1
\
2
\
3
\
4
\
5
\
6
题目中其实并没有说清楚怎么flatten的, 但是观察给的例子后可以发现是把一个节点的左子树插到右子树之前, 原来的右子树放到左子树的最右端叶子节点的右子树位置.
1 | /** |