Problem Description
Given a binary tree A, flatten it to a linked list in-place.
The left child of all nodes should be NULL.
1 <= size of tree <= 100000
First and only argument is the head of tree A.
Return the linked-list after flattening.
Input 1:
1 / \ 2 3
Input 2:
1 / \ 2 5 / \ \ 3 4 6
Output 1:
1 \ 2 \ 3
Output 2:
1 \ 2 \ 3 \ 4 \ 5 \ 6
Explanation 1:
Tree flattening looks like this.
Explanation 2:
Tree flattening looks like this.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.