Skip to content

Commit dd56da9

Browse files
authored
Create n-repeated-element-in-size-2n-array.py
1 parent ef5b1fa commit dd56da9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def repeatedNTimes(self, A):
6+
"""
7+
:type A: List[int]
8+
:rtype: int
9+
"""
10+
for i in xrange(2, len(A)):
11+
if A[i-1] == A[i] or A[i-2] == A[i]:
12+
return A[i]
13+
return A[0]

0 commit comments

Comments
 (0)