Google interview question

Query based problem using Segment Tree/BIT.