Skip to content
Sign in
General Knowledge

What is the time complexity of a loop inside a loop, each running n times?

Tap an option to check the answer. You can also press A–D.

Explanation
A loop inside another loop is called a nested loop. If both loops run n times, the inner loop runs n times for each iteration of the outer loop. Total iterations = n × n = n². Therefore, the time complexity is O(n²).