Algorithm/Online judge

[LeetCode] Array > Contains Duplicate

민철킹 2021. 5. 6. 15:50

leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/578/

 

Explore - LeetCode

LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore.

leetcode.com


풀이

파이썬의 set 자료형을 사용하여 중복 존재 유무 판단

class Solution:
    def containsDuplicate(self, nums: List[int]) -> bool:
        if len(nums) == len(set(nums)):
            return False
        return True
반응형