I am getting a TLE for java implementation of Mo’s algorithm for the problem - https://www.spoj.com/problems/COT2/
The same implementation in cpp is getting accepted under 2s, and worst time it can upto is 10s.
Here’s my implementation of Java code - https://ideone.com/YE0hZg
I have experimented with different blocksizes for Mo algo and found 600 is best for this problem.
What is the best way to implement Mo algo for this problem / What is the best algorithm to implement in java for this problem ?