Guest User

Untitled

a guest
Sep 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. class Solution:
  2. # @param A : tuple of integers
  3. # @return a list of integers
  4. def repeatedNumber(self, A):
  5. A = list(A)
  6. len_A = len(A)
  7. for i in range(len_A):
  8. if(A[abs(A[i])-1]<0):
  9. repeat = abs(A[i])
  10. else:
  11. A[abs(A[i])-1] = - A[abs(A[i])-1]
  12. A = list(map(abs, A))
  13. missing = int((len_A/2*(len_A+1))- (sum(A) - repeat))
  14. return [repeat, missing]
Add Comment
Please, Sign In to add comment