3. Contains Duplicate
Easy · Array
Given an array of integers, determine if the array contains any duplicate elements. Return true if at least one value appears more than once, and false if all elements are unique.
This is a fundamental problem testing your ability to track seen elements efficiently.
Examples
Example 1 Input: [1, 2, 3, 1] Output: true Explanation: The value 1 appears twice (at indices 0 and 3), so the array contains a duplicate.
Example 2 Input: [1, 2, 3, 4] Output: false Explanation: All elements are unique, so there are no duplicates.
Constraints
- Standard input/output constraints apply