Search⌘ K
AI Features

Problem: Contains Duplicate

Understand how to use a HashSet in Java to detect duplicates in an integer array efficiently. This lesson helps you implement a solution with linear time complexity by tracking seen elements and returning true if a duplicate exists, otherwise false.

Statement

Given an integer array nums, determine whether any value appears more than once in the array. Return TRUE if a duplicate exists, and FALSE if all elements are unique.

Constraints:

  • 11 \leq nums.length 105\leq 10^5

  • 1 ...