Time complexity of an algorithm below is O(log(n)), but I'm just curious what is time complexity of the for loop?
func TwoNumberSum(array[] int, target int)[] int {
sort.Ints(array)
left, right: = 0, len(array) - 1
for left < right && left >= 0 && right < len(array) {
if array[left] + array[right] == target {
return [] int {
array[left], array[right]
}
} else if array[left] + array[right] < target {
left += 1
} else {
right -= 1
}
}
return [] int {}
}