Skip to main content

Time Complexity · #67 · 2026-06-10

What's the Big-O?

Python ·Difficulty 2/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), k = max_val. What is the time complexity?

def counting_sort(arr, max_val):
    count = [0] * (max_val + 1)
    for x in arr:
        count[x] += 1
    result = []
    for i, c in enumerate(count):
        result.extend([i] * c)
    return result

Loading your progress...

Press 1 through 4, or tap a numbered choice, to answer. Back to hub