Challenge: Tree to List Conversion using Recursion

Let’s convert a tree to a doubly linked list.

Problem

Given a binary tree, create a doubly linked list from the tree such that the elements are in the order of in-order traversal of the tree.

Input

A binary tree.

Output

The head of the doubly linked list.

Sample input

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.