< Back




217. Contains Duplicate

Really easy question - are there duplicates in this list of integers?

The solution is as follows:


  class Solution:
      def containsDuplicate(self, nums: List[int]) -> bool:
          return len(set(nums)) < len(nums)


_ Time Complexity:

  O(n) - We create a set from a list of integers.

_ Space Complexity:

  O(n) - We create a set from a list of integers.