当前位置:网站首页>Write a method to flatten an array and deduplicate and sort it incrementally
Write a method to flatten an array and deduplicate and sort it incrementally
2022-08-01 03:40:00 【Big chicken thighs are the best】
function solution(arr){
let res=[]
let p=(arr)=>{
for(let i of arr){
if(Array.isArray(i)){
p(i)
}else{
res.push(i)
}
}
}
p(arr)
res=[...new Set(res)]
res.sort((a,b)=>a-b)
return res
}
let a=[1,[12,2,2,2,3,5,[3,[4]]]]
console.log(solution(a))
边栏推荐
- device node结构体转换成platform_device结构体
- Parse the bootargs from the device tree (dtb format data)
- 预言机简介
- 一个service层需要调用另两个service层获取数据,并组装成最后的数据,数据都是list,缓存如何设计?
- button去除黑框
- The 16th day of the special assault version of the sword offer
- Unknown Bounded Array
- 更换树莓派内核
- Guys, MySQL cdc source recycles replication slave and r in incremental process
- Hackers can how bad to what degree?
猜你喜欢
被 CSDN,伤透了心
[uniCloud] Application and Improvement of Cloud Objects
ARM cross compilation
让你的 Lottie 支持文字区域内自动换行
This map drawing tool is amazing, I recommend it~~
【入门教程】Rollup模块打包器整合
带wiringPi库在unbutu 编译 并且在树莓派运行
IDEA modifies the annotation font
Valentine's Day Romantic 3D Photo Wall [with source code]
Software Testing Interview (3)
随机推荐
ARM 交叉编译
Unity在BuildIn渲染管线下实现PlanarReflection的初级方法
MYSQL-Batch insert data
Basic use of vim - command mode
Software Testing Interview (3)
Unknown Bounded Array
测试
Input输入框光标在前输入后自动跳到最后面的bug
787. Merge Sort
win10 fixed local IP
Elastic Stack的介绍
Flutter “Hello world“ 程代码
软件测试基础理论知识—用例篇
2. # 代码注释
button remove black frame
Make your Lottie support word wrapping in text fields
<JDBC> 批量插入 的四种实现方式:你真的get到了吗?
2. # code comments
解决IDEA默认情况下新建文件时,右击,new,没有XML文件的问题
Talking about hardware device computing storage and data interaction