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]);
}
}
}
- O(n)
- O(n log n)
- O(n²)
- O(2ⁿ)
Difficulty: easy