굉장히 쉽다
즉 distinct 한지 아닌지만 확인하면 되기 때문에, 배열의 길이와 set(배열)의 길이가 같은지 다른지만 체크하면 OK.
class Solution(object):
def containsDuplicate(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
if len(set(nums)) == len(nums) :
return False
return True
'leetcode 풀이 > 큐, 스택 (Array)' 카테고리의 다른 글
leetcode 153 - Find Minimum in Rotated Sorted Array (0) | 2022.03.28 |
---|---|
leetcode 152 - Maximum Product Subarray (0) | 2022.03.28 |
leetcode 53 - Maximum Subarray (0) | 2022.03.28 |
leetcode 238 - Product of Array Except Self (0) | 2022.03.26 |
leetcode 121 - Best Time to Buy and Sell Stock (0) | 2022.03.25 |
댓글