DiffPush Tier Binary Trees · Hard O(n) · O(h)
A support org chart is stored as a binary tree of team leads, and when a ticket lands on a specific lead, the audit needs the full escalation trail — every supervisor between the chief and that lead, in order from the top. If the lead id doesn't exist in the chart, the trail comes back empty rather than guessed.
Input: A binary tree as a level-order array (null marks a missing child) and an integer target — the value of the destination node.
Output: Return the array of values on the route from root to the target node, root first. Return an empty array if the target is absent.
1 <= number of nodes <= 10^5-10^4 <= node value <= 10^4Node values are uniqueInput: {"tree":[1,2,3,4,5,null,6],"target":6}
Output: [1,3,6]
The route descends root -> right child 3 -> leaf 6.
Input: {"tree":[1,2,3,4,5,null,6],"target":5}
Output: [1,2,5]
This time the trail bends left: root -> 2 -> 5.