Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion solutions/python/all-unique-characters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@
import unittest

def all_unique(string):

# Optimization that assumes only 256 (2^8) ASCII characters are possible (ignores possibility of unicode)
nLetters = len(letters)
if (nLetters > 256):
return False

letters = sorted(string)
for i in range(len(letters) - 1):
for i in range(nLetters - 1):
if letters[i] == letters[i + 1]:
return False
return True
Expand Down