Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- # @param A : list of integers
- # Modify the array A which is passed by reference.
- # You do not need to return anything in this case.
- def arrange(self, A):
- def ask(x):
- ret = abs(A[x])
- # ja perguntei ?
- if A[x] < 0:
- if A[x] == -(len(A)):
- return 0
- else:
- return ret
- elif A[x] == 0:
- A[x] = -len(A)
- A[x] = ask(0) * len(A)
- else:
- A[x] = -A[x]
- A[x] = ask(-A[x]) * len(A)
- if A[x] == 0:
- A[x] = len(A) ** 2
- return ret
- for i in range(len(A)):
- # sou eu mesmo ?
- if A[i] == i:
- # sim
- A[i] = i * len(A)
- if A[i] == 0:
- A[i] = len(A) ** 2
- # nao
- else:
- # Não sei quem sou
- if A[i] < len(A):
- A[i] = -A[i]
- if A[i] == 0:
- A[i] = -len(A)
- A[i] = ask(A[0]) * len(A)
- else:
- A[i] = ask(-A[i]) * len(A)
- for i in range(len(A)):
- A[i] = A[i] / len(A)
- if A[i] == len(A):
- A[i] = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement