题解 | #查找重复元素#
查找重复元素
https://www.nowcoder.com/practice/871a468deecf453589ea261835d6b78b
{"html":"<!DOCTYPE html>\n<html>\n\n<head>\n <meta charset=\"UTF-8\">\n <style>\n /* 填写样式 */\n </style>\n</head>\n\n<body>\n <!-- 填写标签 -->\n <script type=\"text/javascript\">\n // 填写JavaScript\n function duplicates(arr) {\n const r = {}\n arr.forEach(v=>{\n r[v]>=1 ? r[v]++ : r[v] = 1\n })\n return [...new Set(arr.filter(v=> r[v]>1))]\n }\n </script>\n</body>\n\n</html>","css":"","js":""}