Hello , i am doing cses problem set question Restaurant Customers
here is the link to the question CSES - Restaurant Customers
here is my code
if name == ‘main’:
d = []
n = int(input())
lis = []
for i in range(n):
x,y = map(int,input().split())
if x == 35484384:
flag = 1
lis.append((x,1))
lis.append((y,-1))
lis2 = sorted(lis,key=lambda x:x[0])
count = 0
mx = 0
for i in lis2:
count += i[1]
mx = max(mx,count)
print(mx)
my code fails at this particular case
200000
35484384 332345209
859511920 894165092
893712826 960478308
358444631 882489895
…
times out to be precise . please help me come up with a more time efficient code .