#961

N-Repeated Element in Size 2N Array

newbie · 195 · lc easy +16 · verified · 79.8% accepted · 1,848 likes · top 91%

Description

In integer array nums of length 2n, exactly n + 1 distinct values exist. One value appears exactly n times; every other value appears exactly once. Identify and return the value that occurs n times.

Example 1:

Input: nums = [1,2,3,3]
Output: 3

Example 2:

Input: nums = [2,1,2,5,3,2]
Output: 2

Example 3:

Input: nums = [5,1,5,2,5,3,5,4]
Output: 5

Code

1
2
3