Sir i can not able to pass all the test cases in the question HELP RAHUL TO SEARCH

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 item = sc.nextInt();
	 System.out.println(search( arr , item));


}

public static int search(int[] arr, int item){

    int lo = 0;
    int hi = arr.length - 1;

    while(lo <= hi){

        int mid = (lo + hi) / 2;

        if(arr[mid] > item) hi = mid - 1;
        else if(arr[mid] < item) lo = mid + 1;
        else return mid;
    }

    return -1;
}

}

@abhisheksinghchauhan442
array is rotated so you need to change your approach

  1. Find middle point mid = (l + h)/2
  2. If the key is present at the middle point, return mid.
  3. Else If arr[l…mid] is sorted
  a) If the key to be searched lies in the range from arr[l] to 
     arr[mid], recur for arr[l..mid].
  b) Else recur for arr[mid+1..r]
  1. Else (arr[mid+1…r] must be sorted)
  a) If the key to be searched lies in the range from arr[mid+1]
     to arr[r], recur for arr[mid+1..r].
  b) Else recur for arr[l..mid] 

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.