Contains Duplicate

Easy Sorting

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⁹

Practice this in an AI round

30 minutes on this problem with an AI agent beside your code, then a report on your solution and how you used the agent.

See the AI round

Watch the explanation

More Sorting

All Sorting problems