79814668

Date: 2025-11-09 08:19:13
Score: 0.5
Natty:
Report link

What a lot of answers and I've not seen one that exploits the sort function itself to build the list of duplicates as the original list is sorted. The top answer is order n + n log n. This answer is order n log n.

a = [1,7,2,3,4,5,6,1,4]; 
dups=new Set();
a.slice().sort((a,b)=>{if(a<b) return -1; else if(a>b) return 1; else {dups.add(a);return 0}});
Reasons:
  • Has code block (-0.5):
  • Starts with a question (0.5): What a
  • Low reputation (0.5):
Posted by: CaptainBeOS