当前位置:网站首页>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))
边栏推荐
- Completely closed Chrome updated and in the top right corner of the tip
- button去除黑框
- 如何下载Keil包
- Game Security 03: A Simple Explanation of Buffer Overflow Attacks
- Open source project site must-have & communication area function
- 让你的 Lottie 支持文字区域内自动换行
- MYSQL query interception optimization analysis
- MySQL modifies SQL statements to optimize performance
- Replacing the Raspberry Pi Kernel
- win10 fixed local IP
猜你喜欢
MySQL4
软件测试周刊(第82期):其实所有纠结做选择的人心里早就有了答案,咨询只是想得到内心所倾向的选择。
Valentine's Day Romantic 3D Photo Wall [with source code]
Error using ts-node
[Data analysis] Based on matlab GUI student achievement management system [including Matlab source code 1981]
Which interpolation is better for opencv to zoom in and out??
Software Testing Weekly (Issue 82): In fact, all those who are entangled in making choices already have the answer in their hearts, and consultation is just to get the choice that they prefer.
A way to deal with infinite debugger
button去除黑框
Flutter "Hello world" program code
随机推荐
The fledgling Xiao Li's 113th blog project notes: Wisdom cloud smart flower watering device combat (2) - basic Demo implementation
[cellular automata] based on matlab interface aggregation cellular automata simulation [including Matlab source code 2004]
ARM 交叉编译
MYSQL two-phase commit
MYSQL logical architecture
Chain programming, packages, access
纽约大学等 | TM-Vec:用于快速同源检测和比对的模版建模向量
Replacing the Raspberry Pi Kernel
Raspberry pie arm version of GCC installed configuration and environment variables
JS new fun(); 类与实例 JS基于对象语言 只能通过书写构造函数充当类
Unknown Bounded Array
The IDEA can't find or unable to load The main class or Module "*" must not contain The source root "*" The root already belongs to The Module "*"
Dart 命名参数语法
Introduction to the Elastic Stack
【Make YOLO Great Again】YOLOv1-v7全系列大解析(Neck篇)
手写二叉查找树及测试
【搜索专题】看完必会的BFS解决最短路问题攻略
Basic Theoretical Knowledge of Software Testing - Use Cases
test
MYSQL Keyword Explain Analysis