tried both ways still time limit exceeded
tried both ways still time limit exceeded
Hey @bhattanurag426
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
int n,m;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
cin>>m;
bool found=binary_search(a,a+n,m);
if(found)
{
cout<<lower_bound(a,a+n,m)-a;
}
else cout<<-1; //added
return 0; //corrected (major issue here)
}