Lalit Suthar
1 min readJan 11, 2020

--

Thank you, it helped :)

also a tiny suggestion to save some time by using try-except block instead of calculating length of list.

instead of

if element_ind + 1 < len(lists[list_ind]):
next_tuple = (lists[list_ind][element_ind + 1],
list_ind,
element_ind + 1)
heapq.heappush(heap, next_tuple)

we can do

try:
next_tuple = (lists[list_ind][element_ind + 1],
list_ind,
element_ind + 1)
heapq.heappush(heap, next_tuple)
except IndexError as e:
pass

--

--

Lalit Suthar
Lalit Suthar

No responses yet