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

Problem Note

  • Note that the left child of all nodes should be NULL.

For example

Input: Given the following binary tree 
    1
   / \
  2   5
 / \   \
3   4   6
Output: The flattened tree should look like:
1
 \
  2
   \
    3
     \
      4
       \
        5
         \
          6