Flatten Binary Tree to Linked List

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

Example :
Given


         1
        / \
       2   5
      / \   \
     3   4   6

The flattened tree should look like:

   1
    \
     2
      \
       3
        \
         4
          \
           5
            \
             6

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

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 doubt? Checkout Sample Codes for more details.
Start solving Flatten Binary Tree to Linked List on Interview Code Editor
Sign Up
to access hints and editorial solutions for Flatten Binary Tree to Linked List
6903 successful submissions.
Asked In:
  • Adobe
  • Amazon
  • Microsoft
Click here to start solving coding interview questions