Hi Team,
Instead of storing each list again in min-heap, if store the length of the array and moving index of the array. it reduces space complexity to O(k). please comment on this below.
new min heap parameters array_index,length, instead of list.
def find_Kth_smallest(lists,k):
min_heap=[]
for i in range(len(lists)):
heappush(min_heap,(lists[i][0],0,i,len(lists[i])))
counter=0
while len(min_heap):
#print(min_heap)
num,i,array_index,length=heappop(min_heap)
counter+=1
if counter==k:
break;
if length>i+1:
heappush(min_heap,(lists[array_index][i+1],i+1,array_index,length))
return num