Two almost same solution in java one gets AC and another one gets TLE??

Правка en2, от insane_banda, 2021-10-14 05:14:37

So I just found out that my solution which is almost same as this one gets TLE on test case 8 while latter got AC.

I can't figure-out why this happened?

Problem link -> C.Save More Mice

Solution:

It turns out that Arrays.sort() in java uses Quicksort which has worst time complexity of O(n^2) and Collections.sort() uses that has time complexity of O(nlogn).

refer to this article for more information.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский insane_banda 2021-10-14 05:14:37 285
en1 Английский insane_banda 2021-10-14 04:00:23 431 Initial revision (published)