Skip to content
Problem · Canonical Warm-Up
easyset · hash · sortingTime · O(n)Space · O(n)

Contains Duplicate

Problem walkthrough: statement, hints, solution, mistakes

Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.

Constraints

  • 1 ≤ nums.length ≤ 105
  • -109 ≤ nums[i] ≤ 109

Examples

Input:  [1,2,3,1]  -> true
Input:  [1,2,3,4]  -> false
Input:  [1,1,1,3,3,4,3,2,4,2] -> true