https://app.codility.com/programmers/lessons/3-time_complexity/
정답률: 100%
시간복잡도: O(N)
def solution(A):
lst = []
total = sum(A)
left = 0
for P in range(len(A)-1):
left += A[P]
right = total - left
diff = abs(right-left)
lst.append(diff)
return min(lst)
728x90
반응형
'Problem Solving > Codility' 카테고리의 다른 글
[Python] 4.2. MaxCounters (0) | 2021.03.14 |
---|---|
[Python] 4.1. FrogRiverOne (0) | 2021.03.13 |
[Python] 3.2. PermMissingElem (0) | 2021.03.11 |
[Python] 3.1. FrogJmp (0) | 2021.03.07 |
[Python] 2.2. OddOccurrencesInArray (0) | 2021.03.07 |
댓글