Array - Binary Search Testcase 2 run-error and testcase 1 time limit rest correct

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int[] arr = new int[n];
int i =0;
while(i<n){
arr[i] = scan.nextInt();
i++;
}
int m = scan.nextInt();
int result = binarySearch(arr,m);
System.out.println(result);
}
public static int binarySearch(int[] arr, int m){
int low = 0;
int high = arr.length-1;

    while(low<=high){
        int mid = low+high/2;
        if(arr[mid]>m){
            high=mid-1;
        }
        else if(arr[mid]<m){
            low = mid+1;
        }
        else{
            return(mid);
        }
    }
    return -1;
}

}

Hi Vaibhav,
Mid should be equal to = (low + high)/ 2 and not low + high/2.

Hi @Vaibhav-Garg-1998823966894298
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.