ans = n*m
cnt = 0
dic={}
for i in range(len(track)):
if track[i][0] not in dic:
dic[track[i][0]] = [track[i][1]]
dic[track[i][0]].append(track[i][2])
else:
if(track[i][1]<=max(dic[track[i][0]])):
dic[track[i][0]].append(track[i][1])
dic[track[i][0]].append(track[i][2])
else:
cnt+=track[i][1]-max(dic[track[i][0]])-1
dic[track[i][0]].append(track[i][1])
dic[track[i][0]].append(track[i][2])
print(dic)
sm=0
for i in dic:
m = max(dic[i])
n = min(dic[i])
sm+=m-n+1
return ans-sm+cnt
Please follow and like us: