DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
easy
Array

Contains Duplicate

**Problem Statement:** 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. **Hint / Expected Approach:** Hash set for O(n) detection **Edge Cases to Consider:** - (1) Single-element array - (2) All duplicates - (3) Large input with no duplicates

Examples

Example 1
Input: [1, 2, 3, 1]
Output: True
Example 2
Input: [1, 2, 3, 4]
Output: False
Example 3
Input: [1, 1, 1, 3, 3, 4, 3, 2, 4, 2]
Output: True

Constraints

  • ▪1 <= nums.length <= 10^4
  • ▪-10^9 <= nums[i] <= 10^9
  • ▪Time complexity should be O(n) or O(n log n)

Watch Out For Edge Cases

  • ▪Single-element array
  • ▪All duplicates
  • ▪Large input with no duplicates
Frequently Asked At
AmazonGoogleMetaAdobeTCSInfosys