← 返回 uber 的题目列表Binary Tree Boundary Traversal
类型:online_judge
uber
Given a binary tree, write a function to return the values of the boundary nodes. The boundary should start from the left-bottom, pass through the root, and end at the right-bottom. The time complexity should be O(n), where n is the number of nodes. Provide the structure and constructor for the binary tree.
Example
Input:
1
/ \
2 3
\ \
5 4
Output: [2, 1, 3, 4]
Example
Input
1
2 3
-1 5 -1 4