Rahul -Pivot Binary Search

Why my code failing the first test case

#include
#include
using namespace std;

int main()
{
int n;
cin>>n;
int k;

int arr[n];
for(int i=0;i<n;i++){
    cin>>arr[i];
}
cin>>k;
int s=0,i;
for(i=1;i<n;i++){
    if(arr[i]<arr[i-1]){
        s=i;
        break;
    }

}

int lb1=lower_bound(arr+s+1,arr+n,k)-arr;
if(lb1==n){
int ub=upper_bound(arr,arr+s,k)-arr;
if(ub!=s+1)
cout<<ub-1<<endl;
}
else{
cout<<lb1;
}

}

hello @coderajay03
pls share ur code using cb ide

https://ide.codingblocks.com/s/345905 here is the code .

@coderajay03
check here->

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.