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 53ce7c7 commit 0dab597Copy full SHA for 0dab597
contains-duplicate/hj4645.py
@@ -0,0 +1,10 @@
1
+class Solution:
2
+ # 리스트 안에 동일한 숫자가 2개 이상 존재하면 true를 반환해야 하는 문제
3
+ # Set으로 변환 시 중복이 제거되므로 List와 Set의 크기를 비교해 답을 구할 수 있음
4
+ def containsDuplicate(self, nums: List[int]) -> bool:
5
+ return len(nums) != len(set(nums))
6
+
7
+ # Time Complexity
8
+ # - set(nums) → O(n)
9
+ # - len(nums), len(set(nums)) → O(1)
10
+ # - Total: O(n) (n = number of list elements)
0 commit comments