N-Repeated Element in Size 2N Array

You are given an integer array nums with the following properties:

  • nums.length == 2 * n.
  • nums contains n + 1 unique values, n of which occur exactly once in the array.
  • Exactly one element of nums is repeated n times.

Return the element that is repeated n times.

Example 1
Inputnums = [1,2,3,3]
Output3
The element 3 is repeated 2 times in the array of length 4.
Example 2
Inputnums = [2,1,2,5,3,2]
Output2
The element 2 is repeated 3 times in the array of length 6.

Constraints

  • 2 <= n <= 5000
  • nums.length == 2 * n
  • 0 <= nums[i] <= 10^4
  • nums contains n + 1 unique elements and one of them is repeated exactly n times.

Asked at 6 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate