545. Boundary of Binary Tree

Given the root of a binary tree, return the boundary of the tree in anti-clockwise order: the left boundary, all leaf nodes from left to right, and the right boundary (excluding the root if it is also on the boundary).

Examples
Input: [1,null,2,3,4]
Output: [1,3,4,2]
Hints
Related Problems

545. Boundary of Binary Tree

Given the root of a binary tree, return the boundary of the tree in anti-clockwise order: the left boundary, all leaf nodes from left to right, and the right boundary (excluding the root if it is also on the boundary).