Why this code is not working

i have done this ques from binary search

#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int arr[n]; for(int i=0; i<n; i++) cin>>arr[i]; int noquery; cin>>noquery; int que[noquery]; for(int i=0; i<noquery; i++) cin>>que[i]; int h=-1; for(int i=0; i<noquery; i++){ auto itl=lower_bound(arr,arr+n,que[i]); auto itu=upper_bound(arr,arr+n,que[i]); if((itl-arr)!=n && (itu-arr-1)!=n) cout<<(itl-arr)<<" “<<(itu-arr-1)<<endl; else cout<<h<<” "<<h<<endl; } return 0; }

done found the error

Hello @mohitsingh i have corrected your code and commented the mistake:


if you have any doubt you can ask here;
Happy Learning!!

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.