Burning Tree 2
medium
1. Given a binary tree and target. 2. Find the minimum time required to burn the complete binary tree if the target is set on fire. 3. It is known that in 1 second all nodes connected to a given node get burned. That is, its left child, right child and parent.
Constraints
1. The number of nodes in the tree is in the range [1, 10000]. 2. -1000 <= Node.val <= 1000 3. All the values Node.val are unique. 4. target is the value of one of the nodes in the tree.
Format
Input
Input is managed for you.
Output
Output is managed for you.
Example
Sample Input
15
4
2
1
-1
-1
3
-1
-1
6
5
-1
-1
7
-1
-1
2
Sample Output
2
1 3 4
6
5 7