import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
int[] arr=new int[n];
for(int i=0; i<n;i++){
arr[i]=sc.nextInt();
}
int m=sc.nextInt();
System.out.println(binary(arr,m));
}
public static int binary(int[] arr, int m) {
int li=0;
int hi=arr.length-1;
while(li<=hi){
int mid=li+hi/2;
if (arr[mid] < m) {
li = mid + 1;
} else if (arr[mid] > m) {
hi= mid - 1;
} else {
return mid;
}
}
return -1;
}
}
I wrote the same code but changed the array name to arr to a than it passed all the test case