Time complexity of for

I’m not able to understand how its O(N*N)

    int a = 0;
    for (i = 0; i < N; i++) {
        for (j = N; j > i; j--) {
            a = a + i + j;
        }
    }

It’s something like O(N * N/2) which is still quadratic and therefore O(N*N) :slight_smile:

1 Like

IMG_20200608_195906
Hopefully this will help you understand

1 Like