Back to ArraysContains Duplicate
Easy

Contains Duplicate

EasyRecommendedHashing

Given an array, determine whether any value appears more than once.

Examples

Example 1

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

Explanation: 1 appears twice.

Example 2

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

Example 3

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

Constraints

  • 1 <= nums.length <= 10^5
  • -10^9 <= nums[i] <= 10^9

Loading editor…

Code execution is coming soon.