当前位置:网站首页>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))
边栏推荐
- Summary of JVM interview questions (continuously updated)
- 大佬们,MySQL cdc source在增量过程中回收 replication slave 和 r
- Dart 命名参数语法
- When opening a MYSQL table, some can display editing, some do not, how to set.
- MYSQL logical architecture
- 软件测试基础理论知识—用例篇
- 树莓派 的 arm 版的 gcc 安装 和环境变量的配置
- Compiled on unbutu with wiringPi library and run on Raspberry Pi
- Summary of mobile page optimization in seconds
- 指定set 'execution.savepoint.path'后,重启flinksql报这个错是啥
猜你喜欢

Weekly Summary (*67): Why not dare to express an opinion

Introduction to Oracle

A way to deal with infinite debugger

【消息通知】用公众号模板消息怎么样?

黑客到底可以厉害到什么程度?

HCIP(15)

Software Testing Interview (3)

移动端页面秒开优化总结

Input input box cursor automatically jumps to the last bug after the previous input

【分层强化学习】HIRO:Data-Efficient Hierarchical Reinforcement Learning
随机推荐
button remove black frame
【Make YOLO Great Again】YOLOv1-v7全系列大解析(Neck篇)
TypeScript简化运行之ts-node
Lua introductory case of actual combat 1234 custom function and the standard library function
leetcode6133. 分组的最大数量(中等)
Elastic Stack的介绍
黑客到底可以厉害到什么程度?
Basic implementation of vector
情人节浪漫3D照片墙【附源码】
TypeScript simplifies running ts-node
Soft Exam Senior System Architect Series: Basic Knowledge of System Development
Flutter "Hello world" program code
Ordinary users cannot access HGFS directory
785. 快速排序
The maximum quantity leetcode6133. Grouping (medium)
Replacing the Raspberry Pi Kernel
MySQL4
彻底关闭Chrome浏览器更新及右上角的更新提示
手写二叉查找树及测试
Hackers can how bad to what degree?