Greatings
my id =22647213
can anyone please tell why TLE(time limit exceeded)
def magic(b,diff):
count=0
for i in range(len(b)):
for j in range(i+1,len(b)):
if((b[i]-b[j])==diff):
count=count+1
# break
return count
n,diff=map(int,input().split())
a=list(map(int,input().split()[:n]))
b=sorted(a,reverse=True)
#print(‘sorted list’, b);
print(magic(b,diff))
created
last reply
- 2
replies
- 921
views
- 2
users