Ask a list "is this value in you?" and it looks through its elements one by one to answer. A set answers the same question in one step, however many elements it holds.
seen = set()for v in values:if v in seen:return Trueseen.add(v)return False
The price is memory: you keep what you have seen somewhere. In return two nested loops become one. That trade (give a little memory, gain a lot of time) is the whole of this topic.