Better solution

#include
using namespace std;

int main()
{
int n,a[10000];
cin>>n;
int m=0;
for(int i=0;i<n;i++)
{
cin>>a[i];
if(a[i]>a[i-1])
{
m=i;
}
else
{
break;
}
}
cout<<m;
}

this problem doesnt require binary search to solve.

No your solution is worse. Please explain how is it better than the O(logN) that we get from binary search?

i dont have to use binary search as i calculated my answer while taking inputs only

That’s one way to look at it, but when someone asks, they assume that you already have the array. And given the array you have to design the algorithm. So in that sense your algorithm is linear search.

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.