547. Largest Unique Number
Given an array of integers nums, return the largest integer that appears exactly once. If no integer occurs exactly once, return -1.
Example 1:
Input: nums = [4, 10, 2, 5, 10, 7, 2]
Output: 7
Explanation:
The maximum number is 10, but it appears twice. The largest number that appears only once is 7.
Example 2:
Input: nums = [6, 6, 5, 5, 3]
Output: 3
Explanation:
The number 3 is the only one that appears exactly once.
Now Your Turn!
Pick the correct output for the given inputInput: nums = [12, 12, 9, 9, 15, 8, 8]
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= nums.length <= 2000
- 0 <= nums[i] <= 1000