longest_interval_lists
def longest_interval_lists(m):
heap = []
for i,lst in enumerate(m):
heapq.heappush(heap,(lst[0],i,0))
mn,mx = heap[0][0],max(heap)[0]
max_in_heap = mx
while heap:
x,index,i = heapq.heappop(heap)
if i + 1 == len(m[index]): break
heapq.heappush(heap, (m[index][i+1],index,i+1))
if max_in_heap < m[index][i+1]:
max_in_heap = m[index][i+1]
if max_in_heap - x < mx - mn:
mn,mx = x,max_in_heap
return mn,mx