Yesterday I was doing a question 86D - Powerful array.
I implemented Mo's algorithm and got TLE in java. Then after some modifications in got accepted in 4740 ms (27581138). I started seeing the solution of others users to find ways to optimize my code so that it gets accepted in less time. I came across this solution (14855687) which passed in 2306 ms (almost half). I tried my best to do exactly the same but still my code runs in almost the same time as earlier. This time it was around 4802 ms (27581630).
Can anybody tell me what exactly is the reason behind this and what should I do to pass my submission in less time?
Thanks in advance!