Pregunta de entrevista de Google

Query based problem using Segment Tree/BIT.