The best approach to this is to consider how many steps the algorithm will take.
If you have n elements, you know that the outer loop will work at least n times. Therefore, it must be at least O (n).
How many times does the inner loop have to run for each i? Does it increase, remains unchanged, or decreases as i increases?
It is clear that the number of steps in the inner loop will decrease as i increases, and more importantly, it decreases nonlinearly. So you know that this is not as bad as O (n ^ 2).
So it's somewhere between O (n) and O (n ^ 2) .... a little more analysis on how steps decreasing in the inner loop should get you there. EDIT: ... Although it seems like people already gave it away :)
source share