Given an array of integers nums, return true when at least two values are equal, and false when every value is distinct.
Contains Duplicate (Set 2) — the data. This set runs 4 cases: nums holds arrays of 10–18 items, with values from -30 to 28. The hidden cases are the largest of the set.
Example 1
containsDuplicate()
Input
nums =[1,3,1,6,2,4,3,6,3,6,1,5,4]
Output
true
Why
`containsDuplicate` returns `true`forthisinput.
Example 2
containsDuplicate()
Input
nums =[3,1,1,1,2,6,3,3,1,5,6,2]
Output
true
Why
`containsDuplicate` returns `true`forthisinput.
Constraints
0<=nums.length<=10^5-10^4<= nums[i]<=10^4
Every caseinthisset must pass: the first two are visible on Run, the last two unlock on Submit.
Topics
ArraysHash Table
Implement containsDuplicate in the editor and return the answer — printing it is never graded.