ANUUND-time limit exceeded

I am using insertion sort for this problem.Won’t it work?

Insertion sort wont work it has a complexity of O(n^2), try to solve using quick sort, merge sort or use inbuilt sorting function.

1 Like

If you are using C++, use algorithm header and call the inbuilt sort function, it is faster than others plus you won’t have to write extra code for sorting so your code will be optimum. Also, use fast I/O if you haven’t till now.

Follow this link if you have trouble with the usage:

1 Like