title: Given A Sorted And Rotated Array Find If There Is A Pair With A Given Sum
signature: def given_a_sorted_and_rotated_array_find_if_there_is_a_pair_with_a_given_sum(arr, n, x):
source_py: def given_a_sorted_and_rotated_array_find_if_there_is_a_pair_with_a_given_sum(arr, n, x):
      for i in range(0, (n - 1)):
          if (arr[i] > arr[(i + 1)]):
              break
      l = ((i + 1) % n)
      r = i
      while (l != r):
          if ((arr[l] + arr[r]) == x):
              return True
          if ((arr[l] + arr[r]) < x):
              l = ((l + 1) % n)
          else:
              r = (((n + r) - 1) % n)
      return False
source_cpp: bool given_a_sorted_and_rotated_array_find_if_there_is_a_pair_with_a_given_sum(vector<int> arr, int n, int x) {
    int i;
    for ( i = 0;
    i < n - 1;
    i ++ ) if ( arr [ i ] > arr [ i + 1 ] ) break;
    int l = ( i + 1 ) % n;
    int r = i;
    while ( l != r ) {
      if ( arr [ l ] + arr [ r ] == x ) return true;
      if ( arr [ l ] + arr [ r ] < x ) l = ( l + 1 ) % n;
      else r = ( n + r - 1 ) % n;
    }
    return false;
  }
question_info.test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return actual == expected
  
  def driver(arr, n, x, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              arr, n, x),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver([3, 8, 10, 15, 18, 19, 20, 20, 21, 22, 26, 30, 32, 34, 43, 45, 50, 50, 51, 52, 53, 56, 57, 58, 62, 63, 65, 82, 86, 91, 91, 92, 92, 93, 97], 17, 30, False)
      print(f"TEST-0...{result}")
  
      result = driver([30, -34, 86, -30, -26, 2, 90, 8, 26, -8, -8, 0, -86, 68, 22, 72, -76, 48, -24, 90, -22, -58, -54, 90, -12, -12, 88, 72, -58, 68, 84, 22, 60, 66, -52, -38, -90, 62, 30, -26, 88, -36, 92, 32, -32, -42, -90, -40, -10], 41, 10, False)
      print(f"TEST-1...{result}")
  
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 26, 1, True)
      print(f"TEST-2...{result}")
  
      result = driver([20, 68, 40, 19, 74, 69], 4, 88, False)
      print(f"TEST-3...{result}")
  
      result = driver([-98, -94, -94, -94, -90, -88, -88, -78, -74, -70, -68, -66, -64, -62, -54, -50, -40, -40, -40, -40, -28, -22, -22, -18, -14, -12, 0, 6, 6, 8, 12, 20, 22, 26, 28, 36, 42, 44, 48, 52, 56, 60, 68, 84], 28, 94, False)
      print(f"TEST-4...{result}")
  
      result = driver([1, 1, 0], 2, 60, False)
      print(f"TEST-5...{result}")
  
      result = driver([12, 22, 38, 76, 80, 86], 4, 3, False)
      print(f"TEST-6...{result}")
  
      result = driver([-36, -10, -26, 34, -50, 66, -2, -14, -62, 60, -48, 94, -70, 6, -60, -90, 28, -4, -20, -52, 40, -76, -92, -14, 54, 4, -58, 38, -74, -96, -88, 86, -54, 98, 48, 68, 78, -28, -80, -46], 26, 37, False)
      print(f"TEST-7...{result}")
  
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], 17, 20, False)
      print(f"TEST-8...{result}")
  
      result = driver([69, 99, 25, 52, 41, 51, 7, 33, 42, 91, 85, 57, 91, 89, 86, 11, 70, 67, 30, 92, 81, 23, 51, 98, 85, 5, 50, 44], 21, 27, False)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.entry_fn_name: given_a_sorted_and_rotated_array_find_if_there_is_a_pair_with_a_given_sum
question_info.test_list: [{"idx": 0, "outputs": false, "inputs": {"arr": [3, 8, 10, 15, 18, 19, 20, 20, 21, 22, 26, 30, 32, 34, 43, 45, 50, 50, 51, 52, 53, 56, 57, 58, 62, 63, 65, 82, 86, 91, 91, 92, 92, 93, 97], "n": 17, "x": 30}}, {"idx": 1, "outputs": false, "inputs": {"arr": [30, -34, 86, -30, -26, 2, 90, 8, 26, -8, -8, 0, -86, 68, 22, 72, -76, 48, -24, 90, -22, -58, -54, 90, -12, -12, 88, 72, -58, 68, 84, 22, 60, 66, -52, -38, -90, 62, 30, -26, 88, -36, 92, 32, -32, -42, -90, -40, -10], "n": 41, "x": 10}}, {"idx": 2, "outputs": true, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 26, "x": 1}}, {"idx": 3, "outputs": false, "inputs": {"arr": [20, 68, 40, 19, 74, 69], "n": 4, "x": 88}}, {"idx": 4, "outputs": false, "inputs": {"arr": [-98, -94, -94, -94, -90, -88, -88, -78, -74, -70, -68, -66, -64, -62, -54, -50, -40, -40, -40, -40, -28, -22, -22, -18, -14, -12, 0, 6, 6, 8, 12, 20, 22, 26, 28, 36, 42, 44, 48, 52, 56, 60, 68, 84], "n": 28, "x": 94}}, {"idx": 5, "outputs": false, "inputs": {"arr": [1, 1, 0], "n": 2, "x": 60}}, {"idx": 6, "outputs": false, "inputs": {"arr": [12, 22, 38, 76, 80, 86], "n": 4, "x": 3}}, {"idx": 7, "outputs": false, "inputs": {"arr": [-36, -10, -26, 34, -50, 66, -2, -14, -62, 60, -48, 94, -70, 6, -60, -90, 28, -4, -20, -52, 40, -76, -92, -14, 54, 4, -58, 38, -74, -96, -88, 86, -54, 98, 48, 68, 78, -28, -80, -46], "n": 26, "x": 37}}, {"idx": 8, "outputs": false, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 17, "x": 20}}, {"idx": 9, "outputs": false, "inputs": {"arr": [69, 99, 25, 52, 41, 51, 7, 33, 42, 91, 85, 57, 91, 89, 86, 11, 70, 67, 30, 92, 81, 23, 51, 98, 85, 5, 50, 44], "n": 21, "x": 27}}]
question_info.entry_cls_name: Solution