def squeeze_search(array, target):
left_index = 0
right_index = len(array) - 1
while True:
right_result = squeeze_right(array, target, left_index, right_index)
if right_result is not None:
success, left_index, right_index = right_result
if success:
return True
else:
return False
left_result = squeeze_left(array, target, left_index, right_index)
if left_result is not None:
success, right_index, left_index = left_result
if success:
return True
else:
return False
def squeeze_left(array, target, current_index, left_index):
current_value = array[current_index]
while left_index < current_index:
left_value = array[left_index]
if left_value + current_value == target:
return (True, current_index, left_index)
elif left_value + current_value > target:
return (False, current_index, left_index)
left_index = left_index + 1
return None
def squeeze_right(array, target, current_index, right_index):
current_value = array[current_index]
while right_index > current_index:
right_value = array[right_index]
if right_value + current_value == target:
return (True, current_index, right_index)
elif right_value + current_value < target:
return (False, current_index, right_index)
right_index = right_index - 1
return None
```