Skip to contentKEEP THE CRAFTTHE SANCTUARY

Contains Duplicate

Decide whether any value appears twice by remembering every value you have already seen.

The problem

Implement Solution.containsDuplicate(nums). Return True if some value appears at least twice in nums, and False if every value is different. The list may be empty, and values can be negative, zero or positive.

Starter code

class Solution:
    def containsDuplicate(self, nums):
        pass

Public examples

  1. nums = [4, 11, 4]givesTrue
  2. nums = [4, 11, 18]givesFalse
Open it in the practice book
One thought at a time.