Can someone please tell me what is wrong with this code? I’m new to codechef, and I tried running this with various inputs and logic seems fine to me, i don’t understand what’s wrong, im getting only 40% success

The time complexity of your code is O(N^2) where N is the number of integers in the list.

You have to optimise it further to get rid of TLE.

Hint: Sorting might help.

1 Like