Search⌘ K
AI Features

Problem: Contains Duplicate

Explore how to implement a solution in C# that detects duplicate values in an integer array using a hash set. Understand how this approach offers an efficient O(n) time complexity with O(n) space complexity by tracking seen elements to quickly identify duplicates or confirm uniqueness.

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 ...