Question DSA-CX-0006
EasyWhat is the time complexity of two nested loops, each running n times?
- A.
O(n)
- B.
O(log n)
- C.
Show answer and explanation
Answer: C
The inner loop runs n times for each of the n outer iterations: n × n operations.
Popular companies
Prepare company by company
Hiring pattern, syllabus, past questions and mocks for each company.
All companiesPractice by subject
Complexity Analysis question
What is the time complexity of two nested loops, each running n times?
O(n)
O(log n)
Answer: C
The inner loop runs n times for each of the n outer iterations: n × n operations.
O(n²)
O(2n)