Let's say I have a list:
l = ['a', 'b', 'c', 'd', 'e', 'f', 'e']
As you can see, indexes 4 and 6 are repeated. My question is: What is the most efficient way to see if the list has something repeated in it?
option 1:
output = len(set(l)) != len(l):
If output is false, then there is a value in there more than once.
option 2:
output = True
for i in l:
if l.count(i) > 1:
output = False
If output is false, then there is a value in there more than once.
Questions:
What is the most efficient way of doing this?
How do I calculate the O notation of these two (or more?) options?
Thanks!