Sponsored
Use these hints if you're stuck. Try solving on your own first.
Try to first convert the tree into a sorted array.
How do you solve each query in O(log(n)) time using the array of the tree?
Solve with full IDE support and test cases