Skip to content

Commit

Permalink
Merge pull request #330 from CodyMan0/main
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyMan0 authored Aug 22, 2024
2 parents 559dfdb + c095286 commit 8f47a65
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions contains-duplicate/codyman0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
https://leetcode.com/problems/contains-duplicate/
"""

# Time complexity : O(n)


class Solution:
def containsDuplicate(self, nums: List[int]) -> bool:
sortedArray = sorted(nums)
for i in range(len(sortedArray)):
if i == len(sortedArray) - 1:
return False
if sortedArray[i] == sortedArray[i + 1] :
return True
return False

0 comments on commit 8f47a65

Please sign in to comment.