Understanding the Problem: Contains Duplicate
The “Contains Duplicate” problem is a foundational algorithmic task that asks whether any value appears more than once in a given integer array nums. If any element appears at least twice, the function should return true; if every element is distinct, it should return false.
Example:
Input: [1, 2, 3, 1] → Output: true (1 appears twice)
Input: [1, 2, 3, 4] → Output: false (no duplicates)