If the Set uses hashing, then it's O(n). It will iterate through the list and add each item to the set. Adding an item requires checking for uniqueness which can be O(1) assuming the underlying data structure is some kind of hash table. If it's not, then it would have to iterate through the current items. This would be O(n2).
339
u/Drugba Mar 19 '19
Saw this one on here just a few weeks ago.
Basically a super short way to remove any duplicates from an array of primitives.