Skip to content

Commit be935a0

Browse files
committed
Names was easy
1 parent b1a3db4 commit be935a0

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

names/names.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@
1111
f.close()
1212

1313
duplicates = []
14-
for name_1 in names_1:
15-
for name_2 in names_2:
16-
if name_1 == name_2:
17-
duplicates.append(name_1)
14+
15+
names_cache = {}
16+
17+
for n in names_1:
18+
names_cache[n] = 1
19+
20+
for n in names_2:
21+
if n in names_cache:
22+
duplicates.append(n)
1823

1924
end_time = time.time()
2025
print (f"{len(duplicates)} duplicates:\n\n{', '.join(duplicates)}\n\n")

0 commit comments

Comments
 (0)