Given the root of a binary tree, convert it into a doubly linked list in inorder order. Return the values of the list from head to tail. Pattern focus: Inorder DFS (Left Root Right). The inorder sequence becomes the linked list order.
root = binary tree root
values in the doubly linked list from head to tail
Example 1:
Input:
root = [4,2,5,1,3]
Output:
[1,2,3,4,5]
Explanation:
Inorder traversal of the tree is 1, 2, 3, 4, 5.
Example 2:
Input:
root = [2,1,3]
Output:
[1,2,3]
Explanation:
The doubly linked list follows inorder order.