Back to course home
0% completed
Vote For New Content
[JS] Why not create a set and compare the size to the array.length?
mil o
Dec 16, 2024
Is there a reason why this would not be a good solution? Maybe I am overlooking something here
const uniqueSet = new Set(nums); if (uniqueSet.size !== nums.length) { return true; }
1
0
Comments
Comments
Andre Abtahi9 months ago
that's what i would have done!
H
heliamarasinghe 4 months ago
This is exactly what I did since we dont need to know that numbers are duplicating