I have the following simple algorithm to find duplicate characters in a string:
for i = 1 -> n
for j = i + 1 -> n
if A[i] == A[j] return true
return false
Why is the running time of this algorithm $\mathcal{O}(n^2)$? If the first iteration is $n$ steps then, $n-1, n-2,n-3,..,1$ it seems to me that adding all these would never be $n^2$ or am I wrong?