Problem Description
Given a binary tree, return the reverse level order traversal of its nodes values. (i.e, from left to right and from last level to starting level).
1 <= number of nodes <= 5 * 105
1 <= node value <= 105
First and only argument is a pointer to the root node of the Binary Tree, A.
Return an integer array denoting the reverse level order traversal from left to right.
Input 1:
3 / \ 9 20 / \ 15 7
Input 2:
1 / \ 6 2 / 3
Output 1:
[15, 7, 9, 20, 3]
Output 2:
[3, 6, 2, 1]
Explanation 1:
Nodes as level 3 : [15, 7] Nodes at level 2: [9, 20] Nodes at level 1: [3] Reverse level order traversal will be: [15, 7, 9, 20, 3]
Explanation 2:
Nodes as level 3 : [3] Nodes at level 2: [6, 2] Nodes at level 1: [1] Reverse level order traversal will be: [3, 6, 2, 1]
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.