Medium Accuracy: 26.78% Submissions: 56976 Points: 4

Write a function to print the Boundary Traversal of a binary tree. Boundary Traversal of a binary tree here means that left boundary nodes, leaves, and right boundary in order without duplicatenodes. (The values of the nodes may still be duplicates.)

Note:Left boundary is defined as the path from the root to the left-most node. The right boundary is defined as the path from the root to the right-most node. If the root doesn't have a left subtree or right subtree, then the root itself is left boundary or right boundary. Note this definition only applies to the input binary tree, and not to any subtrees.
For the below tree, the function should print 20 8 4 10 14 25 22 .

Example 1:

Input:
1
/ \
2 3
Output: 1 2 3
Explanation:
The first test case represents a tree
with 3 nodes and 2 edges where the
root is 1, the left child of 1 is 2
and the right child of 1 is 3. And
boundary traversal of this tree
prints nodes as 1 2 3.

Your Task: This is a function problem. You don't have to take input. Just complete the function printBoundary() that takes the root nodeas inputand returns an array containing the boundary values in anti-clockwise.

Expected Time Complexity: O(N). Expected Auxiliary Space: O(Height of the Tree).

Constraints: 1 ≤ Number of nodes ≤ 10^{5} 1 ≤ Data of a node ≤ 10^{5}