Easy · Binary Search
Binary search (recursive)
Given an array of distinct integers sorted in ascending order and a target value, return the index of the target using a recursive search, or -1 if it is not in the array.
Examples
Example 1
{
"values": [1, 3, 4, 6, 8, 9, 11, 14, 17],
"target": 9
}Output: 5
Example 2
{
"values": [1, 3, 4, 6, 8, 9, 11, 14, 17],
"target": 7
}Output: -1
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.