asked
Introduction to Python Algorithm Problem Solving (Coding Test Preparation)
Written on
·
205
0
lt = 0rt = 1total = arr[lt]while(rt < n): if total < m: rt += 1 total = sum(arr[lt:rt]) elif total == m: count += 1 total -= arr[lt] lt += 1 else: total -= arr[lt] lt += 1
print(count)
Answer 1
1
안녕하세요^^
아마 sum(arr[lt:rt])
때문일거라 생각합니다. sum함수의 시간복잡도은 O(n)입니다.