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 ee6f841 commit e336bbdCopy full SHA for e336bbd
Contains Duplicate - Leetcode 217/Contains Duplicate - Leetcode 217.py
@@ -1,3 +1,20 @@
1
+# Brute Force Solution
2
+class Solution:
3
+ def containsDuplicate(self, nums: List[int]) -> bool:
4
+ n = len(nums)
5
+
6
+ for i in range(n):
7
+ for j in range(n):
8
+ if i == j:
9
+ continue
10
+ elif nums[i] == nums[j]:
11
+ return True
12
13
+ return False
14
+ # Time Complexity: O(n^2)
15
+ # Space Complexity: O(1)
16
17
+# Optimal Solution
18
class Solution:
19
def containsDuplicate(self, nums: list[int]) -> bool:
20
h = set()
0 commit comments