This question already has an answer here:
My gut tells me the time-complexity of the following code is simply O(n^2). However, I'm not convinced, thinking it could possibly be O(n^3):
cin >> n; sum = 0; for (int i = 0; i < n; i++) for (int j = 0; j < n * n; j++) sum++;
Can anyone provide a distinction, and why?
Thanks in advance.