Contains Duplicate

Arrays & Hashing, problem 1 of 9

Contains Duplicate

Easy

LC #217

hash setarray

Not attempted yet

Given an integer list nums, return True if some value appears at least twice, and False if every value is distinct.

Example 1

Input: nums = [1, 2, 3, 1]
Output: True

Example 2

Input: nums = [1, 2, 3, 4]
Output: False

Example 3

Input: nums = [4, 1, 4, 4, 2, 1]
Output: True

Constraints

  • 1 ≤ len(nums) ≤ 2 · 10^5
  • -10^9 ≤ nums[i] ≤ 10^9

Python

Loading draft…

Test results

8 tests available

No results yet

Run tests your code against the examples; Submit runs the hidden tests too.

3 examples, 5 hidden

Run examples, then submit all tests.