DEV Community

Discussion on: Find Duplicates in an Array

Collapse
 
xfbs profile image
Patrick Elsen

This is not needed:

uniqueElements.set(sampleData[i], sampleData[i]);

You can just do

uniqueElements.set(sampleData[i], true);

(since you're using the hash map as a set)

Collapse
 
hminaya profile image
Hector Minaya

correct.