Problem

Return the index of target in a sorted array using recursive binary search, or -1 if absent.

Examples

  • binarySearch([1, 3, 5, 7], 5) -> 2
  • binarySearch([1, 3, 5, 7], 4) -> -1
Compile and test (Ctrl+Enter)