We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cb46cb8 commit 77e54f9Copy full SHA for 77e54f9
remove_duplicates.py
@@ -0,0 +1,11 @@
1
+def remove_duplicates(num_array):
2
+ d = dict()
3
+ for idx in range(0, len(num_array)):
4
+ if num_array[idx] in d.keys():
5
+ num_array[idx] = 0
6
+ d[num_array[idx]] = 1
7
+ dedupe_array = [n for n in num_array if n != 0]
8
+ return dedupe_array
9
+
10
+result = remove_duplicates([1, 1, 2, 2, 3, 4, 5])
11
+print(result) # [1, 2, 3, 4, 5]
0 commit comments