Google Interview Question

Query based problem using Segment Tree/BIT.