[
counter
]
Leetcode 0961. N-Repeated Element in Size 2N Array
Problem statement
https://leetcode.com/problems/n-repeated-element-in-size-2n-array/
Solution
We can just calculate counter and choose the most frequent element.
Complexity
It is O(n)
for time and space.
Code
class Solution:
def repeatedNTimes(self, nums):
return Counter(nums).most_common()[0][0]