Quick actions

cmd+k|ctrl+k

Navigation

Languages

Example Big O

Snippet info

Language

JavaScript

Visibility

public

Author

lucassebold5

Created

2025-07-15T16:24:10.121522Z

Updated

2025-07-22T11:14:15.731151Z

function funChallenge(input) {
  let a = 10; // O(1)
  a = 50 + 3; // O(1)

  for (let i = 0; i < input.length; i++) { // O(n)
    anotherFunction(); // O(n)
    let stranger = true; // O(n)
    a++; // O(n)
  }
  return a; // O(1)
}

// 3 + n + n + n + n
// 3 + 4n
// O(3 + 4n)

// o(n) because i am iterating over all the input, its one opetation for each
// item, its linear grow of inputs and opetarions
INFO