Taken from Execute Program
Write a
hasDuplicates
function. It should use a set to decide whether an array of numbers has any duplicates. It should returntrue
if there are duplicates; otherwise it should returnfalse
.
Solution
This is the answer I came up with: