Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- # @param A : tuple of integers
- # @return a list of integers
- def repeatedNumber(self, A):
- A = list(A)
- len_A = len(A)
- for i in range(len_A):
- if(A[abs(A[i])-1]<0):
- repeat = abs(A[i])
- else:
- A[abs(A[i])-1] = - A[abs(A[i])-1]
- A = list(map(abs, A))
- missing = int((len_A/2*(len_A+1))- (sum(A) - repeat))
- return [repeat, missing]
Add Comment
Please, Sign In to add comment