合并二维有序数组成一维有序数组
AwesomeDevin opened this issue · 0 comments
AwesomeDevin commented
- concat + reduce + sort
const arr1 = [[1,2,3,7,9],[1,3,4,6,7,8]]
const arr2 = [[2,5],[4,10]]
function merge(arr1, arr2){
return arr1.concat(arr2).reduce((x,y)=>x.concat(y),[]).sort((x,y)=>x>y?1: -1)
}
merge(arr1,arr2)
- 归并排序