Junior — Senior
Searching for an element in a sorted array using recursion
livecode
Task condition
Create a recursive function that takes a sorted array of integers and a target value. If the value is found, the function should return its index; if not, it should return -1. The goal is to implement the most efficient algorithm.
public class Live {
public static void main(String[] args) {
// example usage
}
public static int searchRecursive(int[] nums, int target, int left, int right) {
// implementation
}
}