Last active
August 29, 2015 14:02
-
-
Save habina/aeb70fa03ad97d370c5a to your computer and use it in GitHub Desktop.
1.1 Implement an algorithm to determine if a string has all unique characters. Whatif you cannot use additional data structures?
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 uniqueString(str): | |
"Return True if the string has all unique characters." | |
allChar = [] | |
for i in range(256): | |
allChar.append(True) | |
for char in str: | |
if(allChar[ord(char)]): | |
allChar[ord(char)] = False | |
else: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for telling me that!