You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
H246802, Gjb7598189, hao0906, cody1991, CaicoLeung and 46 more0qiqi0 and Rednaxela-LinYiyaojiafeng, glong300, 52linxi, cucurbitboy, jianxcao and 2 moreAITuring, jweboy, BarneyLYO, shenqinglin, shojay and 1 more
chengming9731, jerryzhangjie, cucurbitboy, yuanjianhua, chengkai666 and 21 morehanhang123, Fuguangxiong, xiaoyaozi1010, diuleiloumouF and Lemon-Herocucurbitboy, Lemon-Hero, Duex-long and buquanrekkles0905 and LanShiLiangliangzuishuai, infyzz and zhoubaibaiRevluan, chengkai666, fearclear, Eryoo, Syouki-d and 7 more
Activity
Genzhen commentedon Jun 22, 2020
Genzhen commentedon Jun 22, 2020
Genzhen commentedon Jun 22, 2020
hehuilin commentedon Jul 12, 2020
hehuilin commentedon Jul 12, 2020
这个是不是少了排序的功能,只做了将多维数组转换为一维数组
hehuilin commentedon Jul 13, 2020
我是放在前面了呀,不知道你说的意思是要?
SiHao24 commentedon Jul 13, 2020
看错了,不好意思。
123456zzz commentedon Jul 13, 2020
ppmiao0628 commentedon Jul 13, 2020
[[1,2,3],[4,5,6],[7,8,9],[1,2,3],[4,5,6]].flat(Infinity).sort((a,b)=>{ return a-b;})
ppoollaarr commentedon Jul 14, 2020
chengming9731 commentedon Jul 16, 2020
work25 commentedon Jul 16, 2020
HuberTRoy commentedon Jul 16, 2020
40 remaining items
yuxiziyoutiankong commentedon Aug 23, 2021
nhyu commentedon Oct 3, 2021
SnailOwO commentedon Oct 20, 2021
18602435705 commentedon Dec 24, 2021
18602435705 commentedon Dec 24, 2021
ty888 commentedon Jan 6, 2022
listen-amo commentedon Jan 17, 2022
简单来说,应该是归并排序少去从中分割的逻辑部分,直接进行合并排序的操作
kangyana commentedon Feb 15, 2022
chenpengdepot commentedon Feb 25, 2022
function oneArry(arr){
arr=arr.flat();
arr=[...new Set(arr)].sort((a,b)=>{
return a-b
})
return arr;
}
let oldArr=[[1,2,4],[2,3,7],[3,5,7],[4,5,8]]
oldArr=oneArry(oldArr)
console.log(oldArr)
HeroTangMy commentedon Mar 6, 2022
异步解决方案
`const testAry = [
[1, 23, 45, 99],
[4, 8, 9, 15, 48],
[4, 8, 17, 32],
[5, 7, 9]
]
async function tomerge(arr1, arr2) {
let mergedAry = [];
// console.log(arr1,arr2)
let longgerAry = arr1.length > arr2.length ? arr1 : arr2;
let shortAry=arr1.length < arr2.length ? arr1 : arr2;
let j = 0;
let i = 0;
while (shortAry.length != 0 || longgerAry.length != 0) {
if (shortAry.length == 0) {
mergedAry = mergedAry.concat(longgerAry)
break
}
if (longgerAry.length == 0) {
mergedAry = mergedAry.concat(shortAry)
break
}
if (shortAry[0] > longgerAry[0]) {
// console.log(mergedAry)
mergedAry.push(longgerAry.shift())
}
else {
// console.log(mergedAry)
mergedAry.push(shortAry.shift())
}
}
return mergedAry
wringY commentedon Mar 27, 2022
nanmu-yuan commentedon Aug 10, 2022
const arr1 = [[5,9,6],[5,9,6,],[8,9,6]];
const mergeAndSex = (arr)=>[].concat(...arr).sort((a,b)=>a-b)
AAA611 commentedon Aug 25, 2022
题目应该不是要直接把数组展平然后排序,那样的话我直接:
题目说是归并排序的思路,归并排序分为归和并两个过程
题目中给出的是多个有序数组,需要合并为一个有序数组,因此不需要“归”,直接“并”
jakenik commentedon Feb 12, 2024
const mergeList = (...list) => {
return list.flat(Infinity).sort((a, b) => a - b)
}
aaronxdd commentedon Sep 7, 2024
const myFlatSort = (arr) => {
if (!Array.isArray(arr)) return;
return arr.flat().sort();
}