CS Fundamentals Trainer · Algorithms & Data Structures · JavaScript

What is the time complexity of this code?

function printPairs(arr) {
  for (let i = 0; i < arr.length; i++) {
    for (let j = 0; j < arr.length; j++) {
      console.log(arr[i], arr[j]);
    }
  }
}
  1. O(n)
  2. O(n log n)
  3. O(n²)
  4. O(2ⁿ)

Difficulty: easy

Answer this question

Related questions