Solution Link : https://ideone.com/XoFsHQ
Getting TLE!
I have applied mo’s Algorithm and segment tree.
How to optimize it further??
Solution Link : https://ideone.com/XoFsHQ
Getting TLE!
I have applied mo’s Algorithm and segment tree.
How to optimize it further??
The best possible solution is to use iterative segment tree. I modified your code for it and it passed under the time limit .
link for
(https://ideone.com/j7kD2a)