You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a root node of binary tree is given, flatten the binary tree to linked list.
Linked list means that every nodes of the tree connected through the right child.
Linked list should be ordered in pre-order(head first, then left, right direction)
Approach
We can divide tree to three parts. (head, left, right)
Then, flatten left first, connect the right part to the last item of the flattened left part.
Problem
When a root node of binary tree is given, flatten the binary tree to linked list.
Linked list means that every nodes of the tree connected through the right child.
Linked list should be ordered in pre-order(head first, then left, right direction)
Approach
We can divide tree to three parts. (head, left, right)
Then, flatten left first, connect the right part to the last item of the flattened left part.
The code is below.
The text was updated successfully, but these errors were encountered: