General Knowledge
What is the time complexity of a loop inside a loop, each running n times?
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²).