题解 | #查找重复元素#
查找重复元素
https://www.nowcoder.com/practice/871a468deecf453589ea261835d6b78b
function duplicates(arr) { const list = [] const map = {} arr.map(item=>{ if (map[item] == undefined) { map[item] = 1 } else { map[item] += 1 list.push(item) } }) return [...new Set(list)] }