How to find the maximum and minimum element in a range of elements in an array for q queries?
use segment tree