LeetCode 217 Contains Duplicate

LeetCode 217 Contains Duplicate Problem

Download Code
class Solution(object):
    def containsDuplicate(self, nums):
        :type nums: List[int]
        :rtype: bool
        # use set to check duplicate
        return len(nums) != len(set(nums))

    # def containsDuplicate(self, nums):
    #     nums.sort()
    #     for i in range(len(nums) - 1):
    #         if nums[i] == nums[i + 1]:
    #             return True
    #     return False
Download Contains Duplicate.py

List of all Contains Duplicate problems

Leetcode 217 Contains Duplicate problem solution in python3 with explanation. This is the best place to expand your knowledge and get prepared for your next interview.

Feedback is the most important part of any website.

If you have any query, suggestion or feedback, Please feel free to contact us.