leetcode 961.2N数组中的N重复元素
算法思想:因为题中描述为除了重复元素,其余均为非重复元素,则遇到重复元素则为所求。
代码:
class Solution(object):
def repeatedNTimes(self, A):
"""
:type A: List[int]
:rtype: int
"""
length = len(A);
i = 0;
while i<length:
j = i+1;
while j<length:
if A[i] == A[j]:
return A[i];
j = j+1;
i = i+1;