Please help me to find out why my code is giving tle for 3 test cases?
look at the constraints
Constraints
0< n< 10^5
your approach time complexity is O(n^2)
which will definitely give TLE
try to do it in O(nlogn)
Help me think how to improve the complexity.