545. Boundary of Binary Tree

Given the root of a binary tree, return its boundary in anti-clockwise order: the root, the left boundary from top to bottom (excluding leaves), all leaves from left to right, and the right boundary from bottom to top (excluding leaves). A single-node tree returns that node once.

Examples
Input: [-50]
Output: [-50]
Hints

545. Boundary of Binary Tree

Given the root of a binary tree, return its boundary in anti-clockwise order: the root, the left boundary from top to bottom (excluding leaves), all leaves from left to right, and the right boundary from bottom to top (excluding leaves). A single-node tree returns that node once.