The task: Implement an algorithm to determine if a string has all unique characters.
I wrote two functions that dose that. How do I start to asses which one is better/more efficient? what are the things to look for?
this is the first one:
def is_unique(word):
start = 0
len_word = len(word)
while start < len_word:
for i in range(start + 1, len_word):
if word[start] == word[i]:
return False
start += 1
return True
second one:
def unique_list(word):
unique = []
for i in word:
if i in unique:
return False
else:
unique += i
return True