We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8901b1d commit f4ac433Copy full SHA for f4ac433
1 file changed
contains-duplicate/SunaDu.py
@@ -0,0 +1,22 @@
1
+'''
2
+# Leetcode 217. Contains Duplicate
3
+
4
+use set to store distinct elements 🗂️
5
6
+## Time and Space Complexity
7
8
+```
9
+TC: O(n)
10
+SC: O(n)
11
12
13
+### TC is O(n):
14
+- iterating through the list just once to convert it to a set.
15
16
+### SC is O(n):
17
+- creating a set to store the distinct elements of the list.
18
19
20
+class Solution:
21
+ def containsDuplicate(self, nums: List[int]) -> bool:
22
+ return len(nums) != len(set(nums))
0 commit comments