Pergunta de entrevista da empresa Google

Query based problem using Segment Tree/BIT.