Time Complexity · #52 · 2026-05-26
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.
Sorted array of n elements. What is the time complexity?
def two_sum_sorted(arr, target):
lo, hi = 0, len(arr) - 1
while lo < hi:
s = arr[lo] + arr[hi]
if s == target:
return (lo, hi)
elif s < target:
lo += 1
else:
hi -= 1
return None
Loading your progress...
Press 1 through 4, or tap a numbered choice, to answer. Back to hub