题解 | #查找重复元素#
查找重复元素
http://www.nowcoder.com/practice/871a468deecf453589ea261835d6b78b
function duplicates(arr) { const tmp = []; arr.sort((a,b)=>a-b) for(let i = 0 ; i<arr.length;i++){ if(arr[i] == arr[i+1]){ tmp.push(arr[i]) } } let tmp1 = [...new Set(tmp)] return tmp1 }