title: Find Rotation Count Rotated Sorted Array 1
signature: function findRotationCountRotatedSortedArray1(arr: Array<number>, low: number, high: number): number {
source_py: def find_rotation_count_rotated_sorted_array_1(arr, low, high):
      if (high < low):
          return 0
      if (high == low):
          return low
      mid = (low + ((high - low) / 2))
      mid = int(mid)
      if ((mid < high) and (arr[(mid + 1)] < arr[mid])):
          return (mid + 1)
      if ((mid > low) and (arr[mid] < arr[(mid - 1)])):
          return mid
      if (arr[high] > arr[mid]):
          return find_rotation_count_rotated_sorted_array_1(arr, low, (mid - 1))
      return find_rotation_count_rotated_sorted_array_1(arr, (mid + 1), high)
source_cpp: int find_rotation_count_rotated_sorted_array_1(vector<int> arr, int low, int high) {
    if ( high < low ) return 0;
    if ( high == low ) return low;
    int mid = low + ( high - low ) / 2;
    if ( mid < high && arr [ mid + 1 ] < arr [ mid ] ) return ( mid + 1 );
    if ( mid > low && arr [ mid ] < arr [ mid - 1 ] ) return mid;
    if ( arr [ high ] > arr [ mid ] ) return find_rotation_count_rotated_sorted_array_1 ( arr, low, mid - 1 );
    return find_rotation_count_rotated_sorted_array_1 ( arr, mid + 1, high );
  }
question_info.test_list: [{"idx": 0, "outputs": 6, "inputs": {"arr": [4, 16, 38, 39, 48, 74, 79], "low": 6, "high": 6}}, {"idx": 1, "outputs": 0, "inputs": {"arr": [-46, 72, 72, -66, 96, 92, 40, 8, 94, -84, 6, -90, 38, -6, 48, -20, -86, -76, 88, -50, -44, -14, 54, -6, -2, 72, 8, -64, -46, 44, -88, 50, 86, 38, 42, -56], "low": 32, "high": 21}}, {"idx": 2, "outputs": 29, "inputs": {"arr": [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], "low": 16, "high": 29}}, {"idx": 3, "outputs": 24, "inputs": {"arr": [48, 74, 59, 57, 95, 11, 25, 61, 46, 54, 34, 84, 7, 97, 62, 57, 99, 93, 76, 5, 76, 93, 35, 84, 37, 60, 65, 16, 30, 73, 42, 61, 74, 77, 48, 62, 84, 93, 64, 57, 68, 46, 28, 77], "low": 24, "high": 26}}, {"idx": 4, "outputs": 31, "inputs": {"arr": [-72, -68, -66, -66, -62, -62, -52, -48, -42, -42, -42, -38, -30, -22, -20, -20, -16, -16, -14, 0, 2, 2, 2, 4, 12, 20, 22, 26, 32, 34, 46, 46, 64, 64, 64, 66, 68, 68, 68, 74, 80, 84, 84, 88, 88, 90, 96, 98], "low": 29, "high": 43}}, {"idx": 5, "outputs": 0, "inputs": {"arr": [1], "low": 0, "high": 0}}, {"idx": 6, "outputs": 0, "inputs": {"arr": [7, 11, 20, 21, 22, 27, 30, 30, 34, 35, 36, 37, 38, 60, 61, 63, 63, 69, 70, 75, 80, 84, 88, 97], "low": 23, "high": 22}}, {"idx": 7, "outputs": 0, "inputs": {"arr": [-2, 70, -40], "low": 2, "high": 1}}, {"idx": 8, "outputs": 0, "inputs": {"arr": [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], "low": 30, "high": 17}}, {"idx": 9, "outputs": 0, "inputs": {"arr": [71, 71, 27, 10, 97, 43, 55, 71, 6, 6, 77, 48, 77, 2, 83, 51, 61, 19, 2, 51, 26, 70, 20, 23, 54, 15, 6, 92, 35, 75, 8, 57, 50, 49, 88, 21, 36], "low": 24, "high": 22}}]
question_info.entry_cls_name: Solution
question_info.test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(arr: Array<number>, low: number, high: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(arr, low, high),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver([4, 16, 38, 39, 48, 74, 79], 6, 6, 6);
    console.log(`TEST-0...${result}`);
  
    result = driver([-46, 72, 72, -66, 96, 92, 40, 8, 94, -84, 6, -90, 38, -6, 48, -20, -86, -76, 88, -50, -44, -14, 54, -6, -2, 72, 8, -64, -46, 44, -88, 50, 86, 38, 42, -56], 32, 21, 0);
    console.log(`TEST-1...${result}`);
  
    result = driver([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], 16, 29, 29);
    console.log(`TEST-2...${result}`);
  
    result = driver([48, 74, 59, 57, 95, 11, 25, 61, 46, 54, 34, 84, 7, 97, 62, 57, 99, 93, 76, 5, 76, 93, 35, 84, 37, 60, 65, 16, 30, 73, 42, 61, 74, 77, 48, 62, 84, 93, 64, 57, 68, 46, 28, 77], 24, 26, 24);
    console.log(`TEST-3...${result}`);
  
    result = driver([-72, -68, -66, -66, -62, -62, -52, -48, -42, -42, -42, -38, -30, -22, -20, -20, -16, -16, -14, 0, 2, 2, 2, 4, 12, 20, 22, 26, 32, 34, 46, 46, 64, 64, 64, 66, 68, 68, 68, 74, 80, 84, 84, 88, 88, 90, 96, 98], 29, 43, 31);
    console.log(`TEST-4...${result}`);
  
    result = driver([1], 0, 0, 0);
    console.log(`TEST-5...${result}`);
  
    result = driver([7, 11, 20, 21, 22, 27, 30, 30, 34, 35, 36, 37, 38, 60, 61, 63, 63, 69, 70, 75, 80, 84, 88, 97], 23, 22, 0);
    console.log(`TEST-6...${result}`);
  
    result = driver([-2, 70, -40], 2, 1, 0);
    console.log(`TEST-7...${result}`);
  
    result = driver([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], 30, 17, 0);
    console.log(`TEST-8...${result}`);
  
    result = driver([71, 71, 27, 10, 97, 43, 55, 71, 6, 6, 77, 48, 77, 2, 83, 51, 61, 19, 2, 51, 26, 70, 20, 23, 54, 15, 6, 92, 35, 75, 8, 57, 50, 49, 88, 21, 36], 24, 22, 0);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: findRotationCountRotatedSortedArray1
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js