Given a binary tree, flatten it to a linked list in-place.
For example,
Given
1 / \ 2 5 / \ \ 3 4 6
The flattened tree should look like:
1 \ 2 \ 3 \ 4 \ 5 \ 6一开始以为很简单的一题,就是preorder的变种。一开始传了两个参数。把last也当参数传进去。后来发现如果last是参数不能改变后一个递归里面last的值。然后把last作为logbal。搞定。