Set has contains function which returns true if member exists in the set; otherwise, false.
and its complexity is O(1).
I want to know how its complexity is constant O(1) i.e. it does not depends on size
Here are the docs : https://developer.apple.com/documentation/swift/set/1540013-contains
hashValue
. – PhototelegraphySet
. If all elements have the same hash value then the lookup degenerates to O(N). – Nutshell