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
Core interview problems are free with a full runner and lessons; Pro opens the complete library.