Array binary search challenge

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
//array declaration
int [] arr = new int[N];
for(int i = 0; i<=arr.length-1; i++)
{
arr[i] = sc.nextInt();
}
int M = sc.nextInt();
int output = Binary(arr, M);
System.out.println(output);
}
public static int Binary(int [] arr, int M)
{
int low = 0;
int high = arr.length-1;
while(low<=high)
{
int mid = (low + high)/2;
if(M>arr[mid])
{
low = mid + 1;
}
else if(M<arr[mid])
{
high = mid-1;
}
else{
return mid;
}
}
return -1;
}

}
pls hlp ASAP

@Naman_Gupta,
Your code is correct. Will pass all test cases.

You can refresh your browser and then try again. If you still face a problem, kindly drop a mail to [email protected] they will help it out.

It’s a backend technical issue, your code is absolutely correct.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.