TimeComplexity2 [Python] 3.3. TapeEquilibrium https://app.codility.com/programmers/lessons/3-time_complexity/ 3. Time Complexity lesson - Learn to Code - Codility Count minimal number of jumps from position X to Y. app.codility.com 정답률: 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) 2021. 3. 11. [Python] 3.1. FrogJmp https://app.codility.com/programmers/lessons/3-time_complexity/ 3. Time Complexity lesson - Learn to Code - Codility Count minimal number of jumps from position X to Y. app.codility.com 나의 답안 - 정답률 100%, 시간복잡도: O(1) def solution(X, Y, D): if X == Y: return 0 answer = qoutient = (Y-X)//D remainder = (Y-X)%D if remainder != 0: answer = qoutient+1 return answer 2021. 3. 7. 이전 1 다음 728x90 반응형