I got TLE in first four tasks of second sub task(the larger numbers one). What can I optimise more on as I think I using the correct logic of nlogn? Can it be because of python being a bit slower than C/C++?
Or I am missing something.
n, k = map(int, input().split())listOfNumbers = list(map(int, input().split()))sum = 0listOfNumbers.sort()for i in range(n):for j in range(i+1, n):if listOfNumbers[j]-listOfNumbers[i] >= k:sum += n-jbreakprint(sum)