Binary Search Problem

Function below handles a simple search for a needle in a haystack using the binary search algorithm.

The function is called recursively to check if a value is inside the array

See python code below.

Input:
The first line of the input contains an integer n and a sequence a 0 < a 1 < . . . < a n−1 of
n pairwise distinct positive integers in increasing order. The next line contains an integer k and k positive integers b 0 , b 1 , . . . , b k−1 .

Constraints:
1 ≤ n, k ≤ 10 5 ; 1 ≤ a i ≤ 10 9 for all 0 ≤ i < n; 1 ≤ b j ≤ 10 9 for all 0 ≤ j < k;

output: For all i from 0 to k − 1, output an index 0 ≤ j ≤ n − 1 such that  a j = b i or −1 if there is no such index.