Difference in execution time of two almost similar submissions in Java8.

Revision en1, by prabal1815, 2017-06-07 12:00:09

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!

Tags java 8, mos_algorithm, different execution time

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English prabal1815 2017-06-07 12:00:09 760 Initial revision (published)