Is this approach to check duplicates in an array relatively efficient? Why or why not?
问题 I just wanted to check whether there contains any duplicates in my array. I searched on Google and see some approaches: Double for-loop loops though the array and comparing each item Creating a dictionary that stores the number of occurrences of each item But these methods require a lot of loops and I'm kind of lazy to write a large amount of code just for this functionality. xD. So I thought of this creative way: let containsDuplicates = Set(array).count != array.count However, is this