The following algorithm takes in an array, arr (which takes positive and negative values), and a number, target, and finds all pairs of integers in the array that add to give the target number.
def pairs(arr, target):
for i in range(len(arr) - 1):
for j in range(i+1 ,len(arr)):
if arr[i] + arr[j] == target:
print(arr[i], arr[j])
My question is what is the time complexity of this algorithm? I would think it is somewhere between $O(n)$ and $O(n^2)$ as the first for loop is $O(n)$ but the second for loop is not quite $O(n)$ because it doesn't go through the whole array each time. The other steps are $O(1)$.