I have seen sometimes when I sort array it gives TLE but when I sort ArrayList code gets accepted why so?? I have added 2 codes in the first one I have used array, got TLE and in the second one i use arraylist and it got accepted.
(I googled but did not found the reason)
TLE when I used array: https://codeforces.com/contest/600/submission/104404543 Accepted when I use ArrayList: https://codeforces.com/contest/600/submission/104404966
Thanks.
https://codeforces.com/blog/entry/46756
Thanks a lot.
Collections.sort() does some variant of merge sort, while Arrays.sort() for int array is quicksort whose worst cases is quadratic. However, Arrays.sort() for Integer array is merge sort.
Thanks a lot.