Skip to content

Instantly share code, notes, and snippets.

@HauptJ
Created February 9, 2020 02:23
Show Gist options
  • Save HauptJ/874b0281b616e12a276a2ebef34751fb to your computer and use it in GitHub Desktop.
Save HauptJ/874b0281b616e12a276a2ebef34751fb to your computer and use it in GitHub Desktop.
961. N-Repeated Element in Size 2N Array - https://leetcode.com/problems/n-repeated-element-in-size-2n-array/
class Solution:
def repeatedNTimes(self, A: List[int]) -> int:
for i in range(len(A)):
if A.count(A[i]) == len(A)//2:
return A[i]
"""
Input: [1,2,3,3]
Output: 3
size 2N
N+1 unique
N=2
T = 3
Input: [2,1,2,5,3,2]
Output: 2
size 2N
N+1 unique
N=3
T=2
Input: [5,1,5,2,5,3,5,4]
Output: 5
N 5
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment