Skip to content

Instantly share code, notes, and snippets.

@ccapeng
ccapeng / merge_sorted_array_1.py
Created February 23, 2021 23:58
Merge sorted array
import heapq
def merge_arr(arr):
result = []
if len(arr) == 0:
return result
tmp = [] # tmp heap
# push the first item of all subarray into heap
# each heap item is [value, array index, the index inside subarray]