Last active
June 23, 2021 12:28
-
-
Save asraraljuhani/9f9d7136043a2125a2200226b0bc8ba6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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