Question d’entretien chez Google

Query based problem using Segment Tree/BIT.