Problem Description
You are given the root of a complete binary tree A.
You have to return the value of the rightmost node in the last level of the binary tree.
Try to find a solution with a better time complexity than O(N).
A =
1
/
2
Input 2:
A =
1
/ \
2 3
2
Output 2:
3
There is only a single node in the last level of the binary tree.
Therefore, the answer is 2.
Explanation 2:
There a two nodes in the last level of the tree.
The rightmost nodes is 3.
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.