As reported: eBay MTS 1, in-office drive, DSA round 1 (2026): onion-peel order of a binary tree — peel the boundary nodes layer by layer, moving inward.
Draw the binary tree level by level. Every node has four distances to the "outside" of the drawing:
depth— edges from the root (the root has depth 0);height— edges down to the deepest leaf in its own subtree (a leaf has height 0);left— the number of nodes to its left on the same level;right— the number of nodes to its right on the same level.
A node's layer is min(depth, height, left, right). Layer 0 is the outer boundary: the root, every leaf, and the leftmost and rightmost node of every level. Layer 1 is the boundary of what remains, and so on.
Return the layers in order (layer 0 first), each layer's values in level order (top to bottom, left to right). Empty layers are skipped.
Example 1
root = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] (perfect tree, 4 levels)
-> [[1,2,3,4,7,8,9,10,11,12,13,14,15],[5,6]]
Nodes 5 and 6 are the only ones that are not a root, leaf, or level end.
Example 2
root = [1,2,3,4,5,6,7,null,null,8,9]
-> [[1,2,3,4,6,7,8,9],[5]]
Constraints: 0 ≤ number of nodes ≤ 2·10^4; node values are integers.
Code runner format: one line, the tree in LeetCode's level-order format. Implement peelLayers(root); the harness prints the list of layers.