Arjun Mehta2 months agoMost voted8
Count it: n + (n-1) + (n-2) + ... + 1 = n(n+1)/2
That's about n²/2. Big O drops the 1/2, so still O(n²). It is half the work, just not a different growth rate.
It only gets smaller if the inner loop shrinks multiplicatively, like j *= 2, that gives log n.