Skip to content

Commit 33aebaf

Browse files
contains-duplicate solution
1 parent 0e5ffe5 commit 33aebaf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
"""
6+
TC: O(n)
7+
- set(nums): n๊ฐœ ์›์†Œ๋ฅผ ํ•ด์‹œ์…‹์— ์‚ฝ์ž…, ๊ฐ ์‚ฝ์ž… ํ‰๊ท  O(1) โ†’ O(n)
8+
- len()์€ ๋‚ด๋ถ€ size ํ•„๋“œ ๋ฐ˜ํ™˜์ด๋ฏ€๋กœ O(1)
9+
10+
SC: O(n)
11+
- set์ด ์ตœ๋Œ€ n๊ฐœ ์›์†Œ๋ฅผ ์ €์žฅ
12+
"""
13+
def containsDuplicate(self, nums: List[int]) -> bool:
14+
return len(set(nums)) != len(nums)

0 commit comments

Comments
ย (0)