LeetCode 1133, Easy. Topics: Array, Hash Table, Sorting. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 20 parametrized pytest cases, and a playground notebook:
Problem
Given an integer array nums, return the largest integer that only occurs once. If no integer occurs once, return -1.
Examples
Explanation: The maximum integer in the array is 9 but it is repeated. The number 8 occurs only once, so it is the answer.
Explanation: There is no number that occurs only once.
Constraints
- 1 <= nums.length <= 2000
- 0 <= nums[i] <= 1000
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
NeetCode All. Last modified on September 7, 2026