Java Long vs long TLE ?? 439B — 29
Problem : 439B — 29
This seems to be a new discovery for me o_o
My submissions :
long vs Long
Primitive vs a Wrapper Class... How can changing from long to Long suddenly impact the performance? why am I getting TLE with long but not Long ??
I think it's due to the Arrays.sort().
For primitive type it uses Quick sort which takes O(n^2) in worst case. And during object one it uses TimSort.
If you want to use Arrays.sort() for primitive one, shuffle the array before sorting. For example — use knuth shuffle.
I think it's due to the Arrays.sort().
For primitive type it uses Quick sort which takes O(n^2) in worst case. And during object one it uses TimSort.
If you want to use Arrays.sort() for primitive one, shuffle the array before sorting. For example — use knuth shuffle.