Contains Duplicate

Easy Sorting AI round

nums is a list of whole numbers.

A repeat is one value at two or more positions of nums.

Return true if nums has a repeat, and false if every number in it is different from every other.

Example 1

Input: nums = [8,-3,14,0,-3,6]
Output: true

-3 is at positions 1 and 4, so it repeats. Every other number appears once.

Example 2

Input: nums = [12,5,-7,30,1]
Output: false

Example 3

Input: nums = [6,2,6,6,2]
Output: true

Constraints

  • 1 ≤ nums.length ≤ 5 × 10⁵
  • -10⁹ ≤ nums[i] ≤ 10⁹

Watch the explanation

More Sorting

  • Group AnagramsAI round · Medium
  • Maximum GapAI round · Medium
  • Valid AnagramEasy
  • Majority Element IIMedium
  • Find All Duplicates in an ArrayMedium
All Sorting problems