Skip to content

Commit 8f47a65

Browse files
authored
Merge pull request DaleStudy#330 from CodyMan0/main
2 parents 559dfdb + c095286 commit 8f47a65

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

contains-duplicate/codyman0.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
https://leetcode.com/problems/contains-duplicate/
3+
"""
4+
5+
# Time complexity : O(n)
6+
7+
8+
class Solution:
9+
def containsDuplicate(self, nums: List[int]) -> bool:
10+
sortedArray = sorted(nums)
11+
for i in range(len(sortedArray)):
12+
if i == len(sortedArray) - 1:
13+
return False
14+
if sortedArray[i] == sortedArray[i + 1] :
15+
return True
16+
return False

0 commit comments

Comments
 (0)