I am using sorting which leads to nlogn complexity and getting TLE but the same code works on hackerblocks.
TLE for second test case but works on hackerblocks
NlogN complexity is totally fine for it! There’s some problem at backend!,your code is fine.
Mark doubt resolved if satisfied.