Skip to content

Space Complexity

Measures extra memory used by an algorithm.

function sum(arr) {
let total = 0;
for (let num of arr) {
total += num;
}
return total;
}

Space: O(1)