Skip to content

Instantly share code, notes, and snippets.

@asraraljuhani
Last active June 23, 2021 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asraraljuhani/9f9d7136043a2125a2200226b0bc8ba6 to your computer and use it in GitHub Desktop.
Save asraraljuhani/9f9d7136043a2125a2200226b0bc8ba6 to your computer and use it in GitHub Desktop.
def is_unique1(str):
str_set = set()
for char in str:
str_set.add(char.lower())
if(len(str_set) == len(str)):
return True
else:
return False
print(is_unique1("Aqwea")) # False
print(is_unique1("Aaqwe")) # False
print(is_unique1("abc")) # True
def is_unique2(str):
i = 0
for i in range(i,len(str)-1):
j = i+1
for j in range(j,len(str)):
if(str[i].lower() == str[j].lower()):
return False
return True
print(is_unique2("Aqwea")) # False
print(is_unique2("Aaqwe")) # False
print(is_unique2("abc")) # True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment