当前位置:网站首页>编写方法将一个数组扁平化并且去重和递增排序
编写方法将一个数组扁平化并且去重和递增排序
2022-07-31 22:43:00 【大鸡腿最好吃】
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))
边栏推荐
- UOS统信系统 - WindTerm使用
- 基于simulink的Active anti-islanding-AFD主动反孤岛模型仿真
- Summary of the classic drawing method of histogram
- Pytorch lstm time series prediction problem stepping on the pit "recommended collection"
- [QNX Hypervisor 2.2用户手册]9.16 system
- Istio introduction
- Qualcomm cDSP simple programming example (to query Qualcomm cDSP usage, signature), RK3588 npu usage query
- A shortcut to search for specific character content in idea
- SQL注入 Less42(POST型堆叠注入)
- Shell常用脚本:Nexus批量上传本地仓库增强版脚本(强烈推荐)
猜你喜欢
VOT2021比赛简介
Bionic caterpillar robot source code
C#中引用类型的变量做为参数在方法调用时加不加 ref 关键字的不同之处
GateWay implements load balancing
二叉树非递归遍历
Advanced Algebra _ Proof _ Any matrix is similar to an upper triangular matrix
嵌入式开发没有激情了,正常吗?
The article you worked so hard to write may not be your original
Drawing process of hand-drawn map of scenic spots
Handwritten a simple web server (B/S architecture)
随机推荐
IJCAI2022 | 代数和逻辑约束的混合概率推理
Unity - LineRenderer show a line
Design of Fire and Anti-theft System Based on Single Chip GSM
一款国外开发的高质量WordPress下载站模板主题
SQL注入 Less46(order by后的注入+rand()布尔盲注)
Student management system on the first day: complete login PyQt5 + MySQL5.8 exit the operation logic
一文带你了解 Grafana 最新开源项目 Mimir 的前世今生
[QNX Hypervisor 2.2用户手册]9.14 set
The uniapp applet checks and prompts for updates
Pytest first experience
Summary of the classic drawing method of histogram
cas and spin locks (is lightweight locks spin locks)
Write a database document management tool based on WPF repeating the wheel (1)
"SDOI2016" Journey Problem Solution
Judging decimal points and rounding of decimal operations in Golang
Unity-通过预制件和克隆方法动态实现各个UGUI下控件的创建和显示
A few permanent free network transmission, convenient and simple (Intranet through tutorials)
【Acwing】第62场周赛 题解
Several methods of mysql backup table
Fixed-length usage of nanopb string type based on RT1052 Aworks (27)