Time Complexity · #27 · 2026-05-01
What's the Big-O?
Python ·Difficulty 1/3
How to play
Read the code and pick its time complexity from four Big-O choices. Think about loops, recursion, and hidden costs. Press 1–4 or click to answer.
n = len(arr). What is the time complexity?
def max_sum_k(arr, k):
window = sum(arr[:k])
best = window
for i in range(k, len(arr)):
window += arr[i] - arr[i - k]
best = max(best, window)
return best
Loading your progress...
Press 1 through 4, or tap a numbered choice, to answer. Back to hub