Skip to content

Commit a0e417a

Browse files
My soluation for 1.1
1 parent 5b73fd5 commit a0e417a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Python/chapter01/1.1 - Is Unique/camilo_sol.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,18 @@ def isUnique(string_):
1414
#This soluation is O(n^2)
1515

1616
#let's see if we can go faster
17+
18+
def isUnique_(string_):
19+
d = {}
20+
for i in string_:
21+
if i in d:
22+
d[i] += 1
23+
24+
else:
25+
d[i] = 1
26+
for keys,value in d.items():
27+
if value > 1:
28+
return False
29+
return True
30+
31+
print(isUnique_("camilo"))

0 commit comments

Comments
 (0)