Skip to main content
CodeOath
← All problems

Problem

Contains Duplicate

Easy
  • arrays
  • hash-table

Return true if some value shows up in nums more than once, and false if none does.

Example 1
Input
nums = [5, 8, 2, 9, 8]
Output
true
Explanation

8 appears at index 1 and again at index 4.

Example 2
Input
nums = [6, 1, 4, 7]
Output
false
Explanation

all four values are different.

Constraints:

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

Tab indents. Press Esc, then Tab to leave the editor.

Run your code to see every test here. Nothing is submitted or recorded.