Someone said
" try to think this way:
for the first iteration of the outer loop, the inner loop need to run N times, the second iteration of the outer loop, the inner loop need to run N/2 times, third iteration, N/4 times, so add them up, you’ll get N + N/2 + N/4 + … + 1, which is 2N-1, and asymptoticly O(N) "
I can give a similar argument for this loop
for(i = 0; i < n; i ++) {
for(j = 0; j < n; j++) {
}
}
The inner loop runs n times for the first iteration, then again n times for the second iteration, and so on… so its n + n + n… = O(n)