cheetcode

1. Contains DuplicateEasy

Return true when any value appears at least twice in the array.

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.

The goal is to detect duplicates efficiently without comparing every pair of values.

Examples

Input: nums = [1,2,3,1]
Output: true
Explanation: The value 1 appears more than once.
Input: nums = [1,2,3,4]
Output: false
Explanation: Every value is distinct.
Input: nums = [1,1,1,3,3,4,3,2,4,2]
Output: true

Constraints

  • 1 <= nums.length <= 100,000
  • -1,000,000,000 <= nums[i] <= 1,000,000,000