Skip to content
BASA DSA

Contains Duplicate

EasyArrays & Hashing

Return whether any integer occurs more than once in nums.

Example 1

Input
nums = [8,-2,8]
Output
true

Explanation

8 occurs at indices 0 and 2, so a duplicate exists.

Example 2

Input
nums = [1,3,5,7]
Output
false

Explanation

All four values are distinct, so no duplicate is present.

Example 3

Input
nums = []
Output
false

Explanation

The empty array has no equal pair.

Constraints

  • 0 <= len(nums) <= 100000
  • Values are signed 32-bit integers

Function contractcontainsDuplicateArguments: json
Loading draft…
SolutionRuns on your device
Loading draft…