Find the element that appears exactly n times in an array of length 2n where every other element appears once.
You are given an integer array nums of length 2n.
Exactly one value appears n times, and every other value appears exactly once.
Return the value that is repeated n times.
nums of length 2n.n times.n times in the array.2 <= nums.length <= $10^{4}$nums.length is even1 <= nums[i] <= $10^{5}$n timesExample 1
Input
nums = [1,2,3,3]
Output
3
Explanation
The array length is 4, so n = 2. The value 3 appears twice, and the others appear once.
Example 2
Input
nums = [5,1,5,2,5,3,5,4]
Output
5
Explanation
The array length is 8, so n = 4. The value 5 appears 4 times, which is exactly n.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.