verified code for kArrayMerger which merges k sorted arrays to a single array