This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |