LeetCode 217, Easy. Topics: Array, Hash Table, Sorting. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 12 parametrized pytest cases, and a playground notebook:
Problem
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.
Examples
Explanation: The element 1 occurs at the indices 0 and 3.
Explanation: All elements are distinct.
Constraints
- 1 <= nums.length <= 10^5
- -10^9 <= nums[i] <= 10^9
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
Grind 75, Grind, Blind 75, NeetCode 150, NeetCode 250, NeetCode All. Last modified on September 7, 2026