I was solving this problem (the one below) , i see that first two queries are possible with seg tree, but then how can we efficiently do the 3rd query ( i know it is possible using some other algos like sqrt decomposition but I wanted to solve this with a seg tree)

here’s the link to the problem