Skip to main content

Time Complexity · #37 · 2026-05-11

What's the Big-O?

Rust ·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.

Matrix has R rows, C columns (total N = R × C elements). What is the time complexity?

fn flatten_and_sum(matrix: &[Vec<i32>]) -> i32 {
    matrix.iter()
        .flat_map(|row| row.iter())
        .copied()
        .sum()
}

Loading your progress...

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