Given the root of a binary tree, return its boundary traversal: the root, then the left boundary top-down (excluding leaves), then all leaves left to right, then the right boundary bottom-up (excluding leaves). Each node appears once. The tree is given as a level-order array.
Input: A level-order array of the tree.
Output: Array — the boundary in traversal order.
Input: [1,2,3,4,5,6,7]
Output: [1,2,4,5,6,7,3]
Explanation: Root, left edge, leaves, right edge reversed.Input: [1]
Output: [1]
Explanation: Single node.Input: [1,2,null,3]
Output: [1,2,3]
Explanation: Left-only spine.0<=nodes<=10^4-1000<=value<=1000