Basic Algorithms/Binary_Search_Variations.js
// 4 (not the first element)
4 (not the first element)
4 ( not the first element )
function find_first(target, source){
  let index = recursive_binary_search(target, source);
  if (!index){
    return null;
  }
  while(source[index] == target){
    if (index == 0){
      return 0;
    }
    if(source[index-1] == target){
      index -= 1;
    } else{
      return index;
    }
  }
}
function find_first ( target , source ) { let index = recursive_binary_search ( target , source ) ; if ( ! index ) { return null ; } while ( source [ index ] == target ) { if ( index == 0 ) { return 0 ; } if ( source [ index - 1 ] == target ) { index -= 1 ; } else { return index ; } } }
4 (not the first element)
4 ( not the first element )