This is my first entry here, but I have a problem as follows: You are given $$$N$$$ intervals denoted $$$(x,y)$$$, $$$(1 \leq N \leq 10^5)$$$ and $$$(1 \leq x \leq y \leq 10^5)$$$. Answer $$$Q$$$ queries in the form $$$(l,r)$$$, $$$(1 \leq Q \leq 10^5)$$$ and $$$(1 \leq l \leq r \leq 10^5)$$$. So, this is basically a problem of finding the number of segments lying in the given range.
I think that this problem can be solved using Mo's Algorithm in something like $$$O(Q\sqrt{N})$$$.
But if it was just to find the count of given numbers in the given segment, I would've just used Prefix Sum array and answer queries in $$$O(1)$$$. Can there be something similar to this? Or Mo's Algorithm (if I'm not mistaken) is the best here?