545 Boundary of Binary Tree
1. Question
Input:
1
\
2
/ \
3 4
Ouput:
[1, 3, 4, 2]
Explanation:
The root doesn't have left subtree, so the root itself is left boundary.
The leaves are node 3 and 4.
The right boundary are node 1,2,4. Note the anti-clockwise direction means you should output reversed right boundary.
So order them in anti-clockwise without duplicates and we have [1,3,4,2].2. Implementation
3. Time & Space Complexity
Previous543 Diameter of Binary TreeNext105 Construct Binary Tree from Preorder and Inorder Traversal
Last updated