https://app.codility.com/programmers/lessons/6-sorting/
1차시도
Task Score
50%
Correctness
100%
Performance
0%
Detected time complexity
O(N**2)
def solution(A):
cnt = 0
for i in range(len(A)):
for j in range(i+1, len(A)):
if max(A[j], A[i]) >= j-i or j-i <= A[j]+A[i]:
cnt += 1
if cnt > 10 ** 7:
return -1
return cnt
728x90
반응형
'Problem Solving > Codility' 카테고리의 다른 글
[Python] 7.1. Brackets (0) | 2021.03.27 |
---|---|
[Python] 6.4. Triangle (0) | 2021.03.26 |
[Python] 6.2. MaxProductOfThree (0) | 2021.03.25 |
[Python] 6.1. Distinct (0) | 2021.03.25 |
[Python] 5.4. PassingCars (0) | 2021.03.24 |
댓글