Analyze algorithm efficiency with time and space complexity. Big O describes worst-case behavior as input grows: O(1), O(log n), O(n), O(n²), O(2ⁿ).
// O(1)
function getFirst(arr) { return arr[0]; }
// O(n)
function sum(arr) {
let s = 0;
// ...Analyze algorithm efficiency with time and space complexity. Big O describes worst-case behavior as input grows: O(1), O(log n), O(n), O(n²), O(2ⁿ).
// O(1)
function getFirst(arr) { return arr[0]; }
// O(n)
function sum(arr) {
let s = 0;
// ...