Failing for test case n=2 , [3 ,1] and serarch 1

code is submitting perfectly fine here but on leetcode there is error in this test case

also my code here is giving wa for this test case

Muskan, pls change your approach as,

int start=0;
int end=n-1;
while(start<=end)
{
int mid=(start+end)/2;

if(a[mid]==key)
return mid;

if(a[mid]<=a[end])
{
	if(a[mid]<=key && key<=a[end])
    {
        start=mid+1;
    }
	else
    {
	end=mid-1;
    }
}
else
{
    if(a[start]<=key && a[mid]>=key)
    {
        end=mid-1;
    }
    else
    {
        start=mid+1;
    }
}

}
return -1;
}

mam difference hi kya hai???

mam mera hi code pura submit ho gya leetcode par , bs mujhe else if and else vali condition mei = lgana tha

but mera doubt ye hai ki jabh already check kr liya hamne ki vo mid ke equal nhi hai toh baad bhi bhi kyu = sign lgana??

i have updated the code

only i have inserted the = in else if and else conditions

but acc to me , we have already checked whether arr[mid] is = to key or not

so why need to check for equality again?

I have already replied on the chat… Pls refer to it…