Question d’entretien chez Amazon

Segment tree - LeetCode medium Asked to code brute force first and then the optimised solution.